User Tools

Site Tools


proton:android_projects

This is an old revision of the document!


Table of Contents

NEW: 5/23/2012 - Samples now work with latest versions of Android SDK (YOU MUST HAVE THE LATEST SDK TOOLS NOW!) , NDK and Ant, and use new build setup with a java pre-processing step

Intro

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.

First of all there are two versions of Android projects around: the so called v1 and v2. The v1 style is a somewhat deprecated style how Android projects were originally handled in Proton. The v2 version is the current style. Even some of the example applications are still using the v1 style while some of them have been converted to the v2 style. The v1 style is still working but it won't receive any updates and fixes. If you are making a new project, choose the v2 style.

V2 style

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.

Building

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

proton/android_projects.1341245305.txt.gz · Last modified: 2012/07/02 16:08 by aki