我一直在尝试添加应用程序内更新功能,以便用户在 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 关于应用内更新的官方文档。
确保 4 件事,以便您可以测试您的 in_app_update 功能:
祝兄弟好运!
使用内部应用程序共享进行测试
执行以下步骤,使用内部应用程序共享来测试应用程序内更新:
确保您的测试设备安装的应用程序版本符合 支持应用程序内更新并使用内部应用程序安装 分享网址。
按照 Play 管理中心的说明在内部共享您的应用。 上传使用更高版本代码的应用程序版本 比您已经安装在测试设备上的那个要好。
在测试设备上,单击内部应用程序共享链接 更新了您的应用程序版本,但不要从 Play 安装该应用程序 单击链接后出现的商店页面。
从设备的应用程序抽屉或主屏幕打开应用程序。更新 现在应该可用于您的应用程序,您可以测试您的 实施应用内更新。
https://developer.android.com/guide/playcore/in-app-updates/test#internal-app-sharing
import 'package:in_app_update/in_app_update.dart';
@override
void initState() {
updatePopUp();
super.initState();
}
updatePopUp() async {
print('<<<<<<=============<<<<<<< Checked');
await InAppUpdate.checkForUpdate().then(
(value) async {
if (value.updateAvailability == UpdateAvailability.updateAvailable) {
await InAppUpdate.startFlexibleUpdate();
}
},// if print is working then all is ok just call updatePopUP() any
);// where you want to show official update pop up. It worked for
}// IMPORTANT: But It must be installed via Google Play to work.
https://play.google.com/store/apps/details?id=com.abdul.qr_maze