Android 14: SplitInstallStateUpdatedListener never called during installation

40 Views Asked by At

In my Android native application written in Java in which Dynamic features are downloaded on demand. Whilst downloading the progress is displayed with the help of com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener. This listener is then registered with a com.google.android.play.core.splitinstall.SplitInstallManager.

The problem which I am having: the implemented SplitInstallStateUpdatedListener works great on Android 13, but is never called on Android 14. My question is: why is this so?

This is how the split manager listener is registered:

splitInstallManager.registerListener(splitInstallStateUpdatedListener);

The implementation of the SplitInstallStateUpdatedListener looks more or less like this:

return new SplitInstallStateUpdatedListener() {
    @Override
    public void onStateUpdate(SplitInstallSessionState state) {
Log.i(TAG, String.format("SplitInstallSessionState %s", state));

    if (state.sessionId() == mySessionId[0]) {
        List<String> moduleNames = state.moduleNames();
            switch (state.status()) {
                case SplitInstallSessionStatus.DOWNLOADING:                           
                    
                    application.setInstallingModule(module);
                    progressBarHandler.displayLoadingState(state, context.getString(R.string.bundle_download_downloading, getReadableModule(module, context)));
                    break;
                case SplitInstallSessionStatus.DOWNLOADED:
                    application.setInstallingModule(module);
                    break;
                case SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION:
                    try {
                        splitInstallManager.startConfirmationDialogForResult(state, context, CONFIRMATION_REQUEST_CODE);
                    } catch (IntentSender.SendIntentException e) {
                        Log.e(TAG, "Could not send confirmation intent for download of module.");
                    }
                    break;
                case SplitInstallSessionStatus.INSTALLING:
                    application.setInstallingModule(module);
                    progressBarHandler.displayLoadingState(state, context.getString(R.string.bundle_download_installing, getReadableModule(module, context)));
                    break;
                case SplitInstallSessionStatus.INSTALLED:
                    application.setInstallingModule(null);
                    reportInstallSuccess(context, module);
                    progressBarHandler.hideProgress();
                    splitInstallManager.unregisterListener(this);
                    operation.run();
                    break;
                case SplitInstallSessionStatus.FAILED:
                    application.setInstallingModule(null);
                    progressBarHandler.hideProgress();
                    FancyToast.makeText(context, String.format(context.getString(R.string.bundle_install_failed_message), getReadableModule(module, context)),
                            FancyToast.LENGTH_LONG, FancyToast.ERROR, false).show();
                    break;
                case SplitInstallSessionStatus.CANCELING:
                    Log.i(TAG, String.format("Cancelling installation of modules (%s)", moduleNames));
                    break;
                case SplitInstallSessionStatus.CANCELED:
                    application.setInstallingModule(null);
                    progressBarHandler.hideProgress();
                    break;
                default:
                    Log.i(TAG, String.format("Other status for (%s): %d", moduleNames, state.status()));
                case SplitInstallSessionStatus.PENDING:
                    break;
                case SplitInstallSessionStatus.UNKNOWN:
                    break;
            }
        }
    }
}

I have test on a Google Pixel 7 phone with Android 14.

1

There are 1 best solutions below

0
gil.fernandes On

The problem was the usage of the outdated com.google.android.play:core:1.10.3 library.

I have replaced it with the newer libraries:

implementation "com.google.android.play:feature-delivery:2.1.0"
implementation "com.google.android.play:review:2.0.1"

After this the splitInstallStateUpdatedListener started working in Android 14.

See more info here:

https://developer.android.com/guide/playcore