borealis android demo
The Android port of borealis follows SDL's documentation: SDL/docs
Currently, this project uses SDL 2.28.*, but there are some interesting Android-specific features in SDL3. We plan to migrate to SDL3 once it is officially released.
Theoretically, it supports Android API 16 and later (Android 4.1+), but I have only tested it on devices running Android 5.0+ because I couldn't find older devices.
Building
cd android-project
On the Android platform, borealis uses libromfs to package all resource files directly into the shared library. We need to build the libromfs-generator first.
The libromfs-generator is responsible for converting resource files into C++ source code and linking them into the main program during the compilation process.
./build_libromfs_generator.sh
After a successful run, libromfs-generator will be generated in the app/jni directory.
Then open Android Studio and build the project.
# macOS: compile and install from the command line
export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home
export ANDROID_SDK_ROOT=~/Library/Android/sdk
# Once built, the APK will be located in the app/build/outputs/apk/debug directory by default
./gradlew assembleDebug
# Directly install the APK (requires the device or emulator to be connected via adb)
./gradlew installDebug
Migrating your borealis project to Android
- Place your project under the
app/jnidirectory. - Modify
app/jni/CMakeLists.txtand replace the relevant parts of borealis with your project. - Modify the
applicationIdinapp/build.gradleand change it to your package name. - Create your own activity by imitating
com.borealis.demoinapp/src/main/java. - Modify
app/src/main/AndroidManifest.xmland change the package to your package name, and changeDemoActivityto the name of your created activity. - Modify the app name in
app/src/main/res/values/strings.xml. - Replace
app/src/main/res/mipmap-*/ic_launcher.pngwith your application icon.
You can refer to the early commit history of this project to get an idea of what needs to be modified.
Known Issues
If you delete some resource files, libromfs may not recognize it, causing a compilation error. In such cases, a temporary solution is to:
Make a minor adjustment in app/jni/CMakeLists.txt (add an empty line), to trigger cmake to run again.