问题
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