3

I've implemented in-app update in my Android Application with FLEXIBLE update flow. I'm checking and requesting for the update in onCreate() of MainActivity

While updating the app, always install failed with error code -100 which is mentioned at ERROR_INTERNAL_ERROR . Can anyone help me to solve this

val appUpdateManager = AppUpdateManagerFactory.create(this)
appUpdateManager.registerListener { state ->
    if (state.installStatus() == InstallStatus.FAILED) {
        Log.e("::MG::", "appUpdateManager:Status.FAILED")
        Log.e("::MG::", "appUpdateManager:ErrorCode:"+state.installErrorCode())
    }

    if (state.installStatus() == InstallStatus.DOWNLOADED) {
        //sBR(mainhell, resources.getString(R.string.exit))
        val snackbar = Snackbar.make(
            mainhell,
            "Update has been downloaded. \nDo you want to install?",
            Snackbar.LENGTH_INDEFINITE
        )
            .setAction("INSTALL") {
                //If Downloaded Install Update
                val i = Intent(applicationContext, MainActivity::class.java)
                finish()
                startActivity(i)
                appUpdateManager.completeUpdate()
            }
        snackbar.setActionTextColor(Color.YELLOW)
        snackbar.show()

    }
}

val appUpdateInfoTask = appUpdateManager.appUpdateInfo
appUpdateInfoTask.addOnSuccessListener { appUpdateInfo ->
    when {
        appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE &&
                appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE)
        -> {
        appUpdateManager.startUpdateFlowForResult(
                    appUpdateInfo,
                    AppUpdateType.FLEXIBLE,
                    this,
                    FLEXIBLE_UPDATE
                )
        }
        appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED -> {
            if (appUpdateManager != null) {
                appUpdateManager.completeUpdate()
            }
        }
    }
}

Logcate

E/::MG::: appUpdateManager:InstallStatus.FAILED 
E/::MG::: appUpdateManager:installErrorCode:-100
Mahendra Gohil
  • 380
  • 1
  • 3
  • 21

1 Answers1

0

A bit late, but got this and managed to fix it : errcode -100 happens when you try to upgrade to a release apk from a debug one. It will not allow it.

This can happen if you're under a debug mode while developing, and trying to update to an APK published with release flag on the Play Store.

Solution is simply to use same targets release<->release apks update, or debug<-> debug ones (which may not be possible if your app store APK is a release one).

Laurent Perez
  • 548
  • 5
  • 15