[SDL 3.1.6] and Android

I successfully built the required files for Android with cmake and make.

Now I wanted to go further:

### Building the APK's

For the `testsprite` executable, the `testsprite-apk` target will build the associated APK:
`cmake --build . --target testsprite-apk`

APK's of all tests can be built with the `sdl-test-apks` target:
`cmake --build . --target sdl-test-apks`

Where do I have to run this?

cmake --build . --target testsprite-apk

For the *-apk targets to become available, there are 2 requirements:

  • the SDL tests need to be built. So make sure to configure with -DSDL_TEST_LIBRARY=ON -DSDL_TESTS=ON
  • CMake can find the Android build tools and other utilities. Read the docs of the Find*.cmake files in cmake/Android to see what’s needed. Usually, configuring a fresh CMake project with the environment variables ANDROID_HOME and ANDROID_NDK_HOME set is enough (add --fresh to force a fresh build) to let CMake find these utilities automatically.
1 Like

I was able to build the SDL3 package for Android without any errors. As I wrote at the beginning.

But I can’t figure out how to build the APK for the examples and tests.

The SDLTEST_* and SDL_* options you’ve showed will let CMake build the .so files.
For the apk’s to build, you need:

  • all dependencies for the Find*.cmake modules here
  • you also need to configure CMake with a Java JDK (with JAVA_HOME set)

Please note that this apk ability of SDL’s CMake scripts is unsupported.
It was only added to avoid Gradle and build apk’s on ci (=continuous integration).

1 Like

It’s a little more complicated than I thought.