3

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?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
yoonhok
  • 2,575
  • 2
  • 30
  • 58
  • 1
    interesting. I'm getting this error instead: `ERROR_API_NOT_AVAILABLE int ERROR_API_NOT_AVAILABLE The API is not available on this device. Constant Value: -3 (0xfffffffd)` – gmartinsnull Mar 19 '20 at 01:02

2 Answers2

9

If you are working on the emulator, make sure you have Google Play Store installed and signed in.

Emre Memil
  • 233
  • 3
  • 5
4

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.

Community
  • 1
  • 1
Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37