Google Play targetSdkVersion requirements and deadlines

Google Play’s target API policy (Target API level requirements for Google Play apps - Play Console Help) says that every August they update the minimum target API for two things.

One is the minimum API for allowing new apps to be submitted.
The other is the minimum API for allowing apps to be updated.

By August 31, 2023, new apps must target Android 13 (API level 33), while existing apps must target Android 12 (API level 31). “Existing apps must target API level 31 or above to remain available to users on devices running Android OS higher than your app’s target API level. Apps that target API level 30 or below (target API level 29 or below for Wear OS), will only be available on devices running Android OS same or lower than your apps’ target API level.”

In general, new apps and app updates must target an API level within one year from the latest Android OS version, or they risk not being made available for newer Android devices in the Google Play store.

The current android-project/app/build.gradle source shows the targetSdkVersion to be 31.

I haven’t investigated yet if there are any code or configuration changes needed to be compatible with the newer API (I’m hoping most of this doc Behavior changes: Apps targeting Android 13 or higher  |  Android Developers is either easy or irrelevant), but is there current development along these lines to ensure that SDL is ready each August for Google Play’s policy updates?

3 Likes

I don’t have any production code in SDL but I have played around with various SDL examples available online. I have changed targetsdk and compilesdkversion options to 34 and they all work fine

1 Like

Huh, that’s amazing. I had to do more work, and I’m waiting on Google Play to review my changes before I find out if I did the right things, but so far in my own testing it seems to work right.

The way I do Android development, I basically copy the android-project directory out of SDL, then overwrite a few files, such as app/build.gradle, AndroidManifest.xml, Android.mk, app/jni/Application.mk, etc. I use CMake’s configure_file() so applying those changes is part of my build.

So far, the changes I needed to make to support targetSdkVersion 33 included getting a newer SDK and NDK obviously, then moving the project entry out of AndroidManifest into a namespace property in build.gradle.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-  package="org.libsdl.app"
android {
-    compileSdkVersion 31
+    compileSdkVersion 33
+    namespace "org.libsdl.app"
...
-    targetSdkVersion 31
+    targetSdkVersion 33
...
            ndkBuild {
-                arguments "APP_PLATFORM=android-16"
+                arguments "APP_PLATFORM=android-19"

Unfortunately, I ran into problems building for certain ABIs, such as armeabi-v7a and x86, and it wasn’t clear to me why until I changed the minSdkVersion from 16 to 19. I don’t know why, but it seems like the NDK can’t build for those CPUs without running into an error with math.h and not finding log2f:


C/C++: /Projects/Android/android-sdk-linux/ndk/25.1.8937393/sources/cxx-stl/llvm-libc++/include/math.h:1377:93: error: no member named 'log2f' in the global namespace
C/C++: inline _LIBCPP_INLINE_VISIBILITY float       log2(float __lcpp_x) _NOEXCEPT       {return ::log2f(__lcpp_x);}

Eventually I saw the following error, but I want to say it didn’t consistently appear in my build logs when I was investigating it:


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:buildNdkBuildDebug[armeabi-v7a]'.
> com.android.ide.common.process.ProcessException: Android NDK: android-16 is unsupported. Using minimum supported version android-19.

I’m not happy because there were no code changes that prevent the app from running on much older Android devices, but if it isn’t supported, I suppose there isn’t much I can do to keep supporting those devices myself.

Oh, and I needed to update the gradle version both in android-project/build.gradle:

-        classpath 'com.android.tools.build:gradle:7.0.3'
+        classpath 'com.android.tools.build:gradle:8.1.0'

and gradle/wrapper/gradle-wrapper.properties:

-distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip

I think that’s it? I didn’t have to modify any of my own code or anything in the SDL codebase.

The SDL repo has been updated to meet the latest Google Play Store requirements:

2 Likes

Awesome! I was considering forking and contributing based on my notes above, but it looks like you got there first and then some.

FYI, I’ve managed to target 34 and keep 16 as the minimum without any issues. I didn’t get the NDK error. I’m Trying to put together a basic project that works so slouken can hopefully put the minimum back to 16.

1 Like

I’ve also kept the minimum as 16 without any build errors, but I haven’t tried to submit it to the Play Store yet. Have you?

Yep, released on Google Play with all 4 ABIs targeting all form factors. No problem at all. I’ve not been able to reproduce any of the issues others are having.

Which version of the SDK/NDKs are you building against? When I build with targetSdkVersion == 16, I saw issues with the armeabi-v7a and x86 ABIs as I documented above.


$ cmdline-tools/latest/bin/sdkmanager --list
Installed packages:=====================] 100% Computing updates...             
  Path                                        | Version      | Description                                | Location                                   
  -------                                     | -------      | -------                                    | -------                                    
  build-tools;30.0.2                          | 30.0.2       | Android SDK Build-Tools 30.0.2             | build-tools/30.0.2                         
  build-tools;33.0.1                          | 33.0.1       | Android SDK Build-Tools 33.0.1             | build-tools/33.0.1                         
  build-tools;33.0.2                          | 33.0.2       | Android SDK Build-Tools 33.0.2             | build-tools/33.0.2                         
  emulator                                    | 32.1.14      | Android Emulator                           | emulator                                   
  ndk;21.4.7075529                            | 21.4.7075529 | NDK (Side by side) 21.4.7075529            | ndk/21.4.7075529                           
  ndk;25.1.8937393                            | 25.1.8937393 | NDK (Side by side) 25.1.8937393            | ndk/25.1.8937393                           
  ndk;25.2.9519653                            | 25.2.9519653 | NDK (Side by side) 25.2.9519653            | ndk/25.2.9519653                           
  patcher;v4                                  | 1            | SDK Patch Applier v4                       | patcher/v4                                 
  platform-tools                              | 34.0.4       | Android SDK Platform-Tools                 | platform-tools                             
  platforms;android-33                        | 3            | Android SDK Platform 33                    | platforms/android-33                       
  system-images;android-33;google_apis;x86_64 | 13           | Google APIs Intel x86_64 Atom System Image | system-images/android-33/google_apis/x86_64

And in any case, if Google isn’t supporting anything prior to 19, trying to support 16 could result in an impossible support situation in the future.

Thanks, I’ll be trying this myself (min 16, target 34) later this week, so I’ll report back if I have any problems. I actually have a couple of devices I use for testing which are running Android 4.2!

2 Likes

If there was ever going to be an issue, either Android Studio or Google Play Console would flag minSdkVersion 16 as a problem. Neither do, so it’s safe to continue using this as a minimum up to the point it is enforced.

Build tools 33.0.1, NDK 25.2.9519653 (25.1.8937393 also works). I’ve tried various different versions, none of them fail for any of the ABIs. It just works - for my own tweaked projects and also SDL3’s android-project out of the box. Whatever I do, I cannot get it to fail.

Could this be applied to sdl2 too, and possibly a new release of sdl2 2.28.3?

It’s in the SDL2 branch, but a new release would be ideal, especially with the Google Play deadlines requiring urgency.

But I was able to make the changes to the latest release manually and publish my app update a few days ago.

In the future, what would we need to do to keep this kind of change in mind so such an update can be made and added to an official release ahead of time? This time I think it was a fairly lightweight change, but I know in the past there were some major changes by Google Play that required code changes and changes to configuration and permissions, which might require more time to update SDL2.

Is it enough to update the targetSdkVersion after the latest release is officially announced each year?

And on that note, should SDL2 target targetSdkVersion 34 when Android 14 isn’t out of beta yet, instead of 33 which is the latest non-beta release? What I mean is, at any given point, is there an expectation that SDL2 should be considered compatible with the latest Android release or that it is compatible with the latest Android beta release?

I know for me, I would be fine with support/compatibility with the latest official Android release, but I imagine some people want to be able to work with the latest Android beta to ensure that their own apps will be compatible with the next official release ahead of time.

2 Likes

Google is allowing apps to request an extension to the deadline, so especially for this update, it’s not critical that we release an update a couple of days early.

In general we don’t synchronize SDL releases with other company’s deadlines, but there is something coming up that needs urgent attention, you’re always welcome to let us know or cherry-pick a change early into your codebase.

We plan an SDL 2.28.3 release on Friday, but if anyone needs the specific change early, you can cherry-pick it from Updated to Android minSdkVersion 19 and targetSdkVersion 34 · libsdl-org/SDL@cc58a09 · GitHub.

Cheers,

2 Likes