Android, InstallException occurs when I use in-app updates

。_饼干妹妹 提交于 2019-12-19 11:06:26

问题


In Google I/O 2019, In-app update is added newly.

So I am trying to use it following the document: https://developer.android.com/guide/app-bundle/in-app-updates

But it sent an InstallException like:

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)

And my code is here:

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!")
    }
}

I know, it is released just nowadays. But somebody knows this?


回答1:


The error codes are documented in the javadoc.

This says:

int ERROR_INSTALL_NOT_ALLOWED

The download/install is not allowed, due to the current device state (e.g. low battery, low disk space, ...).

Constant Value: -6 (0xfffffffa)

So I suspect your device either does not have space or is not plugged in to power, and the update preferences on this device require power and WiFi.



来源:https://stackoverflow.com/questions/56055230/android-installexception-occurs-when-i-use-in-app-updates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!