androidcrashandroid-app-bundlesideloadinggoogle-play-core

Verify non-Google Play app installs using Play core library


Some context: Most of us may have faced this ResourceNotFoundException when we migrated to Android app bundle release method. It is evident that the issue is because of Side-loading the app. Reference here.

Google recently announced solution to this problem. Using play core library we can identify whether the app is side-loaded or not (Identifies the missing split apks). If the app is side-loaded it shows "Installation failed" popup and redirects to play store, where user can properly install the app via the Google Play store.

Problem: Everything works fine until the installation of missing split apks from play store. Now when I relaunch the app, it immediately crashes with an error saying.

Default FirebaseApp is not initialised in this process

Note: Directly downloading the app from play store works perfectly fine without any crash. The crash happens only when the app re-downloads because of side loading issue.

Code:
Project's build.gradle:

buildscript {
 dependencies {
  classpath 'com.android.tools.build:bundletool:0.9.0'
 }
}

App module's build.gradle:

 implementation 'com.google.android.play:core:1.6.1'

Class that extends Application:

 public void onCreate() {
    if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
        // Skip app initialization.
        return;
    }
    super.onCreate();
    .....
 }

Any help would be really great.


Solution

  • I have solved this issue with the latest version of Play core library:

    App module's build.gradle:

    implementation "com.google.android.play:core:1.7.2"
    

    Other implementation remains same.

    A class that extends Application:

    public void onCreate() {
     if (MissingSplitsManagerFactory.create(this).disableAppIfMissingRequiredSplits()) {
        // Skip app initialization.
        return;
     }
     super.onCreate();
     .....
    }
    

    How to test:

    Hope this helps