Before going in to compilation details check what you need to know about the Android projects in general.
Compiling for Android from Windows (V3 build system)
This is a lot easier than it used to be.
- Install Android Studio
- Make sure everything is working by creating a project using its “Native C++” template. It will automatically download Gradle and the NDK, you should be able to run it on a simulator device and real Android device plugged in.
- Edit the local.properties file in AndroidGradle dir and change RTappID value to your app android package id, and sdk.dir should be set to your Android SDK dir. The package ID must match the one set inside your App.h
- local.properties also has settings for your cert and passwords if needed, this is needed to do release builds for testing, even if Google signs the bundle for you later, I find this is needed to test final releases locally anyway
- Edit AndroidGradle\app\src\main\cpp\CMakeLists.txt and add/remove the C++ files used.
- You should now be able to click build and play or debug.
- Notice that PrepareResources.bat is run when you build a project, it copies assets from bin/interface (etc) to android directories.
- You probably want to edit the app display title and permissions in App/AndroidManifest.xml file. Don't change the RTAndroidApp app id anywhere, it's automatically replaced when you build with what is set in local.properties.
- Note that Main.java is project specific, but the other java files are copied from /shared/Android/v3_src during the build, they are designed to be shared between all proton projects.
- To replace the app icon, in Android Studio right-click the res folder and select New > Image Asset. Set the path to AndroidGradle/app_icon.png (or another file). You should see all icons resized to this image. Click next and save, it will overwrite everything. (see? this is why we used Android Studio now, makes this part really quick) I usually have to do it twice for some reason.
- In Android Studio, I like to choose Run→Edit Configurations, click the Miscellaneous tab and enable “Show logcat automatically” and “Clear log before launch”
I find it easiest to do final builds from the command line.
- Run “BuildFinalBundles.bat” (or type “gradlew bundle” from the command-line. Builds release and debug bundles in AndroidGradle\app\build\outputs\bundle ←- This is the only thing the Play Store will accept for submission now. I recommend letting them sign your builds for you.
Errors and problems
- If you get a weird “clang++: error: no such file or directory” linker error, it's possible your paths are just too long. Even with the max path Win 11 fix I had this issue with one particularly huge fmod library path, so something to keep in mind.
(this is under construction and github may not reflect these latest changes yet)