How to build SDL for Android - CustomSDL/sdl_android_launcher GitHub Wiki
- Clone
sdl_android_launcher
project to your local folder:
git clone https://github.com/CustomSDL/sdl_android_launcher.git
- Change directory to the clonned folder and checkout POC branch:
git checkout feature/android_sdl_port_poc
- Recursively download and update all project submodules at this point:
git submodule update --init --recursive
- Project is ready to work
- Check if you have the necessary NDK version (now it should be 21.0.6113669 in your Android SDK folder).
- Create empty folder for 3rd party libraries:
/home/<usr_name>/android_3rd_party_libs
- Open .bashrc (depending on terminal you are using) in your home folder and add a new function with all your specific paths:
function start_android_studio {
export ORG_GRADLE_NDK_DIR=/home/<usr_name>/Android/Sdk/ndk/21.0.6113669
export THIRD_PARTY_INSTALL_PREFIX=/home/<usr_name>/android_3rd_party_libs
export THIRD_PARTY_INSTALL_PREFIX_ARCH=/home/<usr_name>/android_3rd_party_libs
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$THIRD_PARTY_INSTALL_PREFIX/lib
cd /home/<path-to-android-studio>
android-studio # OR for older versions: bin/studio.sh
}
Note, that this is a one-time action. No need to do it every time.
-
Save the changes and restart the terminal in your system.
-
Open terminal and type
start_android_studio
-
At this point, your Android Studio will be opened with the all required environment variables set, so gradle will be able to forward them to cmake.
- Open Android SDL project
sdl_android_launcher
with the following structure:
- In the bottom left corner, select tab "Build Variants", and chose "Active Build Variant" and "Active ABI" which fits your test device architecture best. The following options are available:
Build Variant | Available ABIs | Comment |
---|---|---|
x86_64 | x86_64 | Used mostly in Android emulators |
x86 | x86 | Used mostly in Android Automotive emulators and in some physical devices |
armeabi_v7a | armeabi_v7a | Used mostly in physical devices |
arm64_v8a | arm64_v8a | Used mostly in physical devices |
universal_build | x86_64, x86, armeabi_v7a, arm64_v8a | Very large APK, but supported by almost any Android device and emulator |
NOTE. In some newer versions of Android Studio there might be not possible to select a certain build variant. If you are faced with such an issue, you can make the following workaround for selecting the required architecture:
- Select
universal_build
in "Active Build Variant" - Select the ABI you want to build in "Active ABI" (for example x86)
- Select the corresponding build variant in in "Active Build Variant" which contains the same ABI (for example x86)
-
Run Gradle (
File
-->Sync Project with Gradle Files
) -
Make project as usual (
Build
-->Make Project
) -
Run custom task
_buildFullSdlApk
to add all necessary shared libraries to bundle: