Before you begin, ensure you have completed the initial steps as described in the root of the repository.
- Eclipse IDE for Java Developers
- Android SDK Tools (24.4.1 or higher)
- Android NDK (r11c or Higher)
First, download the latest eeGeo Android SDK by running the following command in the root of the repository:
./update.platform.sh -p android- We recommend you run this step frequently to keep your SDK version up to date.
The following steps will guide you through installing and setting up the Android SDK, and Eclipse. If you already have these installed and setup, you can skip to here.
- Open Android's SDK Manager, which was installed with the Android SDK Tools
- Install the Android SDK Build-tools (23.0.2)
- Install the Android SDK Platfrorm-tools (23.1)
- Install the SDK platform for the API version to be developed (Min API 24)
- Open Eclipse and select
Help > Install New Software - Select
Addin the top-right corner. - In the Add Repository dialog that appears, enter "ADT Plugin" for the Name, and enter
https://dl-ssl.google.com/android/eclipse/for the Location. - Click
OK. - In the Available Software dialog, select the checkbox next to "Developer Tools" and click
Next. - You'll see a lit of the tools to be downloaded. Click
Nextagain. - Read and accept the license agreements, then click
Finish. - Once the installation is complete, restart Eclipse.
- In Eclipse, go to
File > Switch Workspace > Other... - Select an empty folder to use as a Workspace
- Go to
Eclipse > Preferenceson OSX,Window > Preferenceson Windows. - Find
NDK LocationunderAndroid > NDKand set it to wherever you installed the NDK to. - Right-click on the Package Explorer sidebar and choose
Import... - Select
Android > Existing Android Code Into Workspace - Select the
androidfolder in the Example App and clickFinish - Right click the project, and select
Android Tools > Add Native Support... - Add the cross-platform source by right-clicking the
jnifolder and selectingNew > Folder. - Click
Advancedand select theLinked to alternate locationradio button. - Click
Browse..and select the src directory. - To speed up compile times, see this section below for compiling with multiple threads.
- To run the project, right-click it and select
Run As > Android Application
After selecting an Android device from the dialog, the app should then run as normal.
If you wish to attach a debugger, you will need to build the app in debug mode. You can do this by supplying the NDK_DEBUG option to the ndk-build command. This is done as follows:
- Right-click the project and select Properties
- Under C/C++ Build, uncheck "Use default build command".
- In the "Build command" field, add the
NDK_DEBUGoption:ndk-build NDK_DEBUG=1
See the NDK documentation for more details on the NDK_DEBUG option and how it interacts with the android:debuggable option in the Android manifest.
-
Compiling on multiple threads:
- Right-click the project and select
Properties - Under C/C++ Build, uncheck "Use default build command".
- In the "Build command" field, add the option
-jN, where N is the number of threads to use. - For example:
ndk-build -j4to use 4 threads
- Right-click the project and select
-
Reducing the number of architectures:
- By default, the project is compiled for three different architectures: armeabi, armeabi-v7a, and arm64-v8a.
- If you do not need all of these, or you wish to quickly test on a single architecture, you can remove some of them from Application.mk.
- For example:
APP_ABI := armeabi
Some developers have experienced a deadlock when adding native support to the project. The IDE hangs, and the project is left in a corrupted and unrecoverable state. The following steps mitigate this issue:
- Destroy the corrupted Eclipse workspace by deleting the metadata Eclipse creates in android directory. The metadata are:
- .classpath file
- .project file
- .cproject file
- .settings directory
- Create the workspace again as described in Setting up the project
- Delete the contents of Android.mk.
- Add native support to the project
- Revert the change to Android.mk
Some developers have experienced an issue where the project hangs while building for the first time, with the message "Invoking scanner config builder on project". The following steps mitigate this issue:
- Cancel the build
- Build the project
- Right-click on the project in Eclipse's Project Explorer
- Select Properties
- Select the "Builders" option on the left hand side of the properties dialog
- Untick "Scanner Configuration Builder"
- Press OK on the subsequent warning dialog
- Build the project
You can re-enable the functionality after the initial build has completed.
