Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 643
Naveen T P Avatar asked Jun 23 '19 15:06

Naveen T P


People also ask

What is Google Play Core Library?

What is the Google Play Core Library? From Google's Android Development Documentation: The Play Core Library is your app's runtime interface with the Google Play Store. Some of the things you can do with Play Core include the following: Download additional language resources.

What is core library in Android?

The Mapbox Core Libraries for Android are a set of utilities that help you with permissions, device location, and connectivity within your Android project. With these libraries, you can: Check for, request, and respond to any number of Android system permissions such as device location or camera.


1 Answers

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:

  • A better way to test it properly is to release the app bundle with these above fixes in play store internal test channel (Add yourself as a tester).

  • Simulate installing invalid apks - Use bundletool to get .apks file out of bundle, extract it and install base_master.apk using adb command adb install base_master.apk.

  • Launch the app, you should see "Installation failed" dialog and it redirects to Play store, clicking on Update, play store will install the missing apks.

  • Launching the app should work properly by now.

Hope this helps

like image 172
Naveen T P Avatar answered Sep 28 '22 06:09

Naveen T P