Posted by Vikas Kansal, Product Manager, Google Play providers

The Android Jelly Bean (JB) platform was first launched 9 years in the past and as of July 2021, the energetic gadget depend is under 1%. Since then Android has launched a number of enhancements and options which aren’t all backported to Jelly Bean. This leads to elevated developer and QA time spent on new options that require particular dealing with. Consequently, we’re deprecating assist for JB in future releases of Google Play providers. For gadgets working JB, Google will not replace the Play Services APK past model 21.30.99, scheduled for the tip of August 2021.

What does this imply as an Application developer:

The Google Play providers SDKs comprise the interfaces to the performance supplied by the Google Play providers APK, which runs as background providers. The performance required by the present, launched SDK variations is already current on JB gadgets with Google Play providers and can proceed to work with out change.

Each SDK may be independently launched and will replace its personal minSdkVersion. Individual libraries should not required to alter based mostly on this deprecation. Newer SDK parts could proceed to assist API ranges 16 via 18 however many will replace to require the upper API ranges. For purposes that assist API ranges 19 or larger, you’ll not must make any modifications to your construct. For purposes that assist API ranges 16 via 18, chances are you’ll proceed to construct and publish your app to gadgets working JB, however chances are you’ll encounter construct errors when updating to newer SDK variations. The error will appear to be this:

Error:Execution failed for activity ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 can't be smaller than model 19 declared in library [com.google.android.gms:play-services-FOO:19.X.YY]
        Suggestion: use instruments:overrideLibrary="com.google.android.gms:play_services" to power utilization

Unfortunately, the acknowledged suggestion is not going to aid you present app updates to gadgets working JB or older. In order to make use of the newer SDK, you’ll need to make use of one of many following choices:

1. Use API stage 19 because the minimal supported API stage.

This is the beneficial plan of action. To discontinue assist for API ranges that may not obtain Google Play providers updates, merely enhance the minSdkVersion worth in your app’s construct.gradle to at the very least 19. If you replace your app on this method and publish it to the Play Store, customers of gadgets with lower than that stage of assist won’t be able to see or obtain the replace. However, they’ll nonetheless have the ability to obtain and use essentially the most just lately revealed model of the app that does goal their gadget.

A really small proportion of all Android gadgets are utilizing API ranges lower than 19. We imagine that many of those outdated gadgets might not be actively getting used. If your app nonetheless has a big variety of customers on older gadgets, you should utilize a number of APK assist in Google Play to ship an APK that makes use of Google Play providers 21.30.99. This is described under.

2. Build a number of APKs to assist gadgets with an API stage lower than 19.

Along with some configuration and code administration, you may construct a number of APKs that assist completely different minimal API ranges, with completely different variations of Google Play providers. You can accomplish this with construct variants in Gradle. First, outline construct flavors for legacy and newer variations of your app. For instance, in your construct.gradle, outline two completely different product flavors, with two completely different compile dependencies for the parts of Play Services you are utilizing

productFlavors {
    legacy {
        minSdkVersion 16
        versionCode 101  // Min API stage 16, v01
    }
    present {
        minSdkVersion 19
        versionCode 1901  // Min API stage 19, v01
    }
}

dependencies {
    legacyCompile 'com.google.android.gms:play-services:16.0.0'
    currentCompile 'com.google.android.gms:play-services:17.0.0'
}

In the above state of affairs, there are two product flavors being constructed in opposition to two completely different variations of play-services-FOO. This will work advantageous if solely APIs are known as which are obtainable within the 16.0.0 library. If it’s worthwhile to name newer APIs made obtainable with 17.0.0, you’ll have to create your personal compatibility library for the newer API calls in order that they’re solely constructed into the model of the appliance that may use them:

  1. Declare a Java interface that exposes the higher-level performance you need to carry out that’s solely obtainable in present variations of Play providers.
  2. Build two Android libraries that implement that interface. The “current” implementation ought to name the newer APIs as desired. The “legacy” implementation ought to no-op or in any other case act as desired with older variations of Play providers. The interface ought to be added to each libraries.
  3. Conditionally compile every library into the app utilizing “legacyCompile” and “currentCompile” dependencies as illustrated for play-services-FOO above.
  4. In the app’s code, name via to the compatibility library each time newer Play APIs are required.

After constructing a launch APK for every taste, you then publish them each to the Play Store, and the gadget will replace with essentially the most acceptable model for that gadget. Read extra about a number of APK assist within the Play Store.