User Tools

Site Tools



The Android projects are a bit more complicated than some other platforms. Most of the complication comes from the fact that the Android applications are a mixture of native C++ and interpreted Java code. This is true for any Android project (not just Proton) that uses native code. On top of this Proton also adds its own quirks.

Over the years we've updated how Android compiling works because Android itself keeps changing.

V1 style: Lost to the sands of time (outdated) V2 style: Used Ant and preprocessor directives, tricky but worked (outdated) V3 style: Using Android Studio/Gradle, a very normal looking project, nothing weird about it really.

V2 style (outdated!)

At some point in history it came apparent that on Android some Java classes (provided by Proton) need to be in specific packages. And these packages change from project to another. Hence it was necessary to introduce a way to get (almost) the same source files to different directories (and thus to different packages) in different projects. The source files also needed small modifications in the code, for example the package name needs to be specified in the source.

The solution invented for this was to use a preprocessor tool and a set of scripts that modify the sources and put them to correct directories. The preprocessor used is called JavaPP and it is included in the Proton source (${PROTON_DIR}/shared/android/util/javapp.jar).

Basically what happens is that the scripts take a bunch of (both C++ and Java) source files from ${PROTON_DIR}/shared/android/ and run them through the preprocessor inserting correct package names and other strings in to them. The resulting files are also organized into a correct directory structure.

The preprocessor is similar to the C preprocessor but not quite the same. See the README in the ${PROTON_DIR}/shared/android/util directory for details.

A set of directories are used in the process, all prefixed with the string temp_:

  • temp_src contains all the Java source files in a correct directory structure but before the preprocessing
  • temp_final_src contains all the Java source files after the preprocessing
  • temp_final_cpp_src contains C++ source files after preprocessing

When the Android project is built C++ files from temp_final_cpp_src and Java files from temp_final_src are compiled in to the project. Specifically Java files from the src directory are not compiled since they have not gone through the preprocessing step yet.

The build scripts also include some optional Java code (like Google's billing stuff, Tapjoy or Hooked) into the project as needed. What gets copied needs to be set per project.

V3 style

After a few more years, Seth created an Android Studio/Gradle based build. The preprocessor is no longer used and the build system is simplified quite a bit, you just change the package id in a single place (AndroidGradle/ and edit a CMakeLists.txt file to set which C/C++ files compile. Android Studio can load the project and run/debug on devices or emulated devices very easily.

Android Studio handles installing Gradle/NDK/etc by itself, much simpler than before.

Note: I've ripped out built in support (on the Java side) for In App Billing, Chartbooost/Tapjoy/Etc as I assume they don't work anymore anyway as I haven't used them for years.

It is possible to use third party libraries the “gradle way” or directly by linking files, I do this in Dink Smallwood HD android for FMOD support.

IMPORTANT NOTE: The package ID set in App.cpp MUST match the one set in Those are the only two places you need to worry about it. The RTAndroidApp name you see everywhere stays that way and shouldn't be changed. (it's used for internal bindings but won't affect the real build's package id etc)


The building process is somewhat different depending on what operating system you are using. Check instructions for Windows or Linux

Or the old outdated way: Windows or Linux.

proton/android_projects.txt · Last modified: 2022/08/01 07:41 by seth