Flutter AppUpdateService linkToDeath

问题描述

我一直在尝试添加应用程序内更新功能,以使用户在Playstore中有可用的新更新时更新应用程序。我正在使用软件包in_app_update

但是它总是抛出该错误

I/PlayCore( 8420): UID: [10378]  PID: [8420] AppUpdateService : requestUpdateInfo(com.example.app)
I/PlayCore( 8420): UID: [10378]  PID: [8420] AppUpdateService : Initiate binding to the service.
I/PlayCore( 8420): UID: [10378]  PID: [8420] AppUpdateService : ServiceConnectionImpl.onServiceConnected(ComponentInfo{com.android.vending/com.google.android.finsky.installservice.DevTriggeredUpdateService})
I/PlayCore( 8420): UID: [10378]  PID: [8420] AppUpdateService : linkToDeath
I/PlayCore( 8420): UID: [10378]  PID: [8420] OnRequestInstallCallback : onRequestInfo
I/PlayCore( 8420): UID: [10378]  PID: [8420] AppUpdateService : Unbind from service.
W/JavaBinder( 8420): BinderProxy is being destroyed but the application did not call unlinkToDeath to unlink all of its death recipients beforehand.  Releasing leaked death recipient: com.google.android.play.core.internal.ac

我正在使用的代码

try {
  if (Platform.isAndroid) {
    InAppUpdate.checkForUpdate().then((info) {
      setState(() {
        _updateInfo = info;
      });
    }).catchError((error) => print(error));

    if (_updateInfo?.updateAvailable == true) {
      InAppUpdate.performImmediateUpdate()
          .catchError((error) => print(error));
    }
  }
} catch(e) {
    print(e);
}

在使用上述软件包几天后,我尝试使用另一个名为native_updater的软件包。此程序包也导致相同的错误。尽管我遵循了他们的榜样,但应该可以。

Flutter doctor输出

Doctor summary (to see all details,run Flutter doctor -v):
[✓] Flutter (Channel master,1.22.0-10.0.pre.121,on Linux,locale en_US.UTF-8)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Android Studio (version 4.0)
[✓] Connected device (1 available)


我找不到任何类似的问题或答案,这就是为什么要发布一个

我正在使用64位Kali Linux计算机。

解决方法

起初,我和你有同样的问题。但我注意到,必须从Play商店下载该应用,并且还必须有更新。如果通过从flutter或vscode启动应用程序来执行此操作,则正常运行是不正常的。我不知道我是否很清楚。

请注意,此插件无法在本地测试。必须通过Google Play安装它才能正常工作。请查看有关来自Google的应用内更新的官方文档。