androidandroid-api-levelsandroid-api-30

My Android app is not working properly once I set targetSDK as API 30; how do I figure out the reason(s)?


According to Google, all new Google Play apps from August 2021 would need to target API 30, besides being derived as Android App Bundles. Furthermore, from November 2021, even app updates would need to conform.

So I was updating my app from targeting API 29 to API 30, and some functions broke. How do I figure out the reason(s)? From the list of changes given by Google, it is not obvious, as it is not just a matter of checking whether certain deprecated APIs are being used.

Ideally, if Android Studio might provide a way to see how features in API 30 affect my app behavior, that would be cool.


Solution

  • I discovered a cool feature in Android Developer options, called App Compatibility Changes. Google describes these Compatibility Framework Tools in this way:

    Android 11 introduced new developer tools for testing and debugging your app against the behavior changes in newer versions of the Android platform. These tools are part of a compatibility framework that lets app developers turn breaking changes on and off individually using developer options or ADB. Use this flexibility as you prepare to target the latest stable API version and as you test your app with the preview release of the next Android version.

    Wow, and looking at it on the phone, it appears you can actually toggle each new feature/change on or off individually?

    App Compatibility Tools in Developer options

    Well, let's see; first it gives us a list of all the debuggable apps on the device, and if we select one of them, say, targeting API 29, then we can actually toggle on/off each API 30 feature individually, as shown in the example below, with CALLBACK_ON_CLEAR_CHANGE.

    Toggling on an individual feature of API 30

    Cool! Just two points to note: this works with debuggable apps only; and if you're wanting to turn on/off features of API 30, build your debuggable app targeting the API level below it, i.e., API 29 in this case, and then turn on/off features and test away! If you've no idea which feature is causing the problem(s), you can speed up the search by selecting, say, half of the 30 or so changes, see if the problem(s) are there or not, and so on, to zoom in to the right toggles.