Android,当我使用应用内更新时发生InstallException

yoo*_*hok 3 android google-play in-app-update google-play-core

Google I/O 2019 新增应用内更新。

所以我尝试按照文档使用它:https ://developer.android.com/guide/app-bundle/in-app-updates

但它发送了一个 InstallException,如下所示:

com.google.android.play.core.tasks.RuntimeExecutionException: com.google.android.play.core.install.InstallException: Install Error: -6
    at com.google.android.play.core.tasks.k.getResult(Unknown Source:18)
    at com.eastriver.workingtimer.ui.MainActivity$onCreate$1.onComplete(MainActivity.kt:35)
Run Code Online (Sandbox Code Playgroud)

我的代码在这里:

val appUpdateManager = AppUpdateManagerFactory.create(this)
val appUpdateInfo = appUpdateManager.appUpdateInfo
appUpdateInfo.addOnCompleteListener {
    val result = it.result
    if (result.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE
                    && result.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)) {

        info("should show update")
        appUpdateManager.startUpdateFlowForResult(
            result,
            AppUpdateType.FLEXIBLE,
            this,
            1)
    } else {
        info("This is already latest version!")
    }
}
Run Code Online (Sandbox Code Playgroud)

我知道,它是今天才发布的。但有人知道这个吗?

小智 9

如果您使用模拟器,请确保您已安装并登录 Google Play 商店。