Google Play Services Stopping Updates for Jelly Bean (API Levels 16, 17 and 18)



Posted by Development Console, Product Manager, Google Play Services

The Android Jelly Bean (JB) platform was first released 9 years ago and as of July 2021, the number of active devices is less than 1%. Since then Android has released a lot of improvements and features that are not all backported to Jelly Bean. This results in increased developer and QA time spent on new features that require special handling. As a result, we are deprecating support for JB in future releases of Google Play Services. For devices running JB, Google will no longer update the Play Services APK beyond version 21.30.99, which is scheduled for the end of August 2021.

What does this mean as an application developer:

The Google Play Services SDK contains an interface to the functionality provided by the Google Play Services APK, which runs as background services. The functionality required for current, released SDK versions already exists on JB devices with Google Play Services and will continue to work without change.

Each SDK can be released independently and update its own minSdkVersion. There is no need to change individual libraries based on this deprecation. New SDK components may continue to support API levels from 16 to 18, but many will be updated to require higher API levels. For applications that support API level 19 or higher, you will not need to make any changes to your build. For applications that support API levels 16 to 18, you can continue to build and publish your app on devices running JB, but you may encounter build errors when updating to newer SDK versions. The error will look like this:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.android.gms:play-services-FOO:19.X.YY]
        Suggestion: use tools:overrideLibrary="com.google.android.gms:play_services" to force usage

Unfortunately, the suggested suggestion won’t help you provide app updates on JB or older devices. To use the new SDK, you must use one of the following options:

1. Use API level 19 as the minimum supported API level.

This is the recommended course of action. To turn off support for API levels that will no longer receive updates to Google Play Services, simply increase the minSdkVersion value in your app’s build.gradle to at least 19. If you update your app in this way and publish it to the Play Store, users devices with support below that level will not be able to view or download the update. However, they will still be able to download and use the most recently published version of the app that targets their device.

A very small percentage of all Android devices are using API levels less than 19. We believe that many of these older devices are not being actively used. If your app still has a significant number of users on older devices, you can use the Multiple APK support in Google Play to deliver an APK that uses 21.30.99 in Google Play Services. It is described below.

2. Build multiple APKs to support devices with API level less than 19.

With some configuration and code management, you can create multiple APKs with different versions of Google Play Services that support different minimum API levels. You can accomplish this with build variants in Gradle. First, define the build flavors for the legacy and newer versions of your app. For example, in your build.gradle, define two different product flavors, with two different compile dependencies for the Play Services components you are using

productFlavors {
    legacy {
        minSdkVersion 16
        versionCode 101  // Min API level 16, v01
    }
    current {
        minSdkVersion 19
        versionCode 1901  // Min API level 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 situation, there are two product flavors being built against two different versions of play-services-FOO. It will work fine if only APIs are called which are available in 16.0. If you need to call the new APIs provided with 17.0.

  1. Declare a Java interface that exposes the high-level functionality you want to perform that is only available in current versions of Play Services.
  2. Create two Android libraries that implement that interface. The “current” implementation should call the new API as desired. With older versions of Play Services the “legacy” implementation should work as no-op or otherwise as desired. The interface must be linked in both libraries.
  3. Conditionally compile each library using the “legacyCompile” and “currentCompile” dependencies illustrated for play-services-FOO above.
  4. In the code of the app, whenever the new Play API is needed, make a call to the compatibility library.

After creating a release APK for each flavor, you then publish them both to the Play Store, and the device will be updated with the most appropriate version for that device. Read more about Multiple APK support in Play Store.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *