inApp Update, download but not installed



I have a problem with inapp update. A new version window appears, when you press the “Update now” button, unfortunately nothing happens, the application downloads in the background, but nothing happens app is not updated. I would like to add that I am testing it on the “Open Test” in play store path.

    private void checkForUpdate() {
        appUpdateManager
            .getAppUpdateInfo()
            .addOnSuccessListener(
                appUpdateInfo -> {

                    // Checks that the platform will allow the specified type of update.
                    if ((appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE)
                            && appUpdateInfo.isUpdateTypeAllowed(AppUpdateType.FLEXIBLE))
                    {
                        // Request the update.
                        try {
                            appUpdateManager.startUpdateFlowForResult(
                                    appUpdateInfo,
                                    AppUpdateType.FLEXIBLE,
                                    this,
                                    REQUEST_APP_UPDATE);
                        } catch (IntentSender.SendIntentException e) {
                            e.printStackTrace();
                        }
                    }
                });
    }

Answer

You are using the FLEXIBLE method for updating the App, which will download the app but will not auto-update it.

You have to monitor the flexible update progress and once the update is downloaded, you have to install it manually.

     private val installStateUpdatedListener = InstallStateUpdatedListener { state ->
            when (state.installStatus()) {
                InstallStatus.DOWNLOADED -> completeUpdate()
                InstallStatus.FAILED -> reportUpdateFailure(state.installErrorCode())
                else -> {
                    // Right now we only care about download success / failed state
                }
            }
        }

// Before starting an update, register a listener for updates.
appUpdateManager.registerListener(listener)

// Start an update.

// When status updates are no longer needed, unregister the listener.
appUpdateManager.unregisterListener(listener)

Once the update is downloaded, you have to call appUpdateManager.completeUpdate() to complete the update.

You can get more information here: https://developer.android.com/guide/playcore/in-app-updates/kotlin-java#flexible



Source: stackoverflow