Developing for Android
- Ensure that your system has the correct dependencies installed to build Navit.
- Checkout the latest copy of Navit from svn. The instructions on this page assume you have checked-out a copy to ~/src/navit-svn/
cd ~/src svn co svn://svn.code.sf.net/p/navit/code/trunk/navit navit-svn
- Download the Android NDK and SDK.
- Unzip the SDK and NDK to a directory of your choice. The following instructions assume that the SDK and NDK have been unzipped to ~/src.
- Ensure that the following paths are on your PATH environment variable:
path-to-sdk/tools path-to-sdk/platform-tools path-to-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin
- On Ubuntu you can accomplish this using the following command (assuming the SDK and NDK have been unzipped to ~/src):
export ANDROID_NDK=~/src/android-ndk-r8 export ANDROID_SDK=~/src/android-sdk-linux export PATH=$PATH:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$ANDROID_SDK/tools:$ANDROID_SDK/platform-tools
(double check the version numbers in the paths and adapt if required)
- Prepare Android SDK:
- run android in command line - this will show a GUI for preparing Android SDK
- select Android 2.2 (API 8) and click 'Install N packages...' button - this will download SDK packages that support API 8
Assuming you've followed the previous steps, you're probably setup to start compiling. Using CMake is the recommended way of compiling Navit for Android. Ensure that:
- You have a java-jdk installed on your system. On Ubuntu:
sudo apt-get install openjdk-6-jdk
- On Ubuntu, ensure that ant1.8 is installed:
sudo apt-get install ant1.8
- Make sure that you have saxonb-xslt installed:
sudo apt-get install libsaxonb-java
- Ensure that you have CMake 2.8 installed.
- Create a build directory - this will be the directory into which the Android version of Navit will be built. Assume we've made one in ~/src as follows:
cd ~/src mkdir android-build
- Optional: Add a SOURCE_PATH environment variable to your system, pointing to the directory in which you checked out a copy of Navit. You can leave out this step, but make sure you change $SOURCE_PATH in the next steps to the actual path of the directory.
- Step into the build directory:
- Run CMake (ensure that you're in the build directory when you do this!):
cmake -DCMAKE_TOOLCHAIN_FILE=$SOURCE_PATH/Toolchain/arm-eabi.cmake -DCACHE_SIZE="(20*1024*1024)" -DAVOID_FLOAT=1 -DANDROID_PERMISSIONS="CAMERA" -DANDROID_API_VERSION=8 -DXSLT_PROCESSOR=/usr/bin/saxonb-xslt $SOURCE_PATH
- Build the apk package:
make make apkg
- The previous commands have now created a package called Navit-debug.apk in the following directory:
- Copy the package to your device (i.e. sd-card) and run it from there (through a file-manager, for example), or
- If debug bridge (adb) is enabled run:
adb install navit/android/bin/Navit-debug.apk
- Later, to reinstall already installed Navit app run:
adb install -r navit/android/bin/Navit-debug.apk
- Run ./autogen.sh from the navit dir.
cd ~/src/navit-svn/ ./autogen.sh
- Make sure you have
- $ANDROID_NDK pointing to your ndk installation
- $ANDROID_API_LVL set to 4
- $ANDROID_NDK/toolchains/arm-eabi-*/prebuilt/linux-x86/bin in your $PATH
- $ANDROID_PLATFORM set to $ANDROID_NDK/platforms/android-$ANDROID_API_LVL/arch-arm
- Run something like
./configure \ PKG_CONFIG=arm-eabi-pkgconfig \ RANLIB=arm-eabi-ranlib \ AR=arm-eabi-ar \ CC="arm-eabi-gcc -L$ANDROID_PLATFORM/usr/lib -L. -I$ANDROID_PLATFORM/usr/include" \ CXX=arm-eabi-g++ \ --host=arm-eabi-linux_android \ --enable-avoid-float \ --enable-avoid-unaligned \ --enable-cache-size=20971520 \ --enable-svg2png-scaling=8,16,32,48,64,96 \ --enable-svg2png-scaling-nav=59 \ --enable-svg2png-scaling-flag=32 \ --with-xslts=android,plugin_menu,pedestrian_button,pedestrian \ --with-saxon=saxonb-xslt \ --enable-transformation-roll \ --enable-plugin-pedestrian \ --with-android-permissions=CAMERA \ --with-android-project="android-$ANDROID_API_LVL"
- Run make
- cd navit
- Run make apkg
The result is in android/bin as Navit-debug.apk
Even easier is it to use this hopefully foolproof build script. Since r4507, it is part of navit. From the navit-main-directory, call it with ./contrib/android_build.sh. Good luck!
With cmake on Windows
- install CMake 2.8 if you haven't already, add folder with exe to PATH
- install MinGW or use MinGW included in the git windows folder (e.g. C:\msysgit\mingw\), add folder with exe to PATH
- install saxon .NET version from http://sourceforge.net/projects/saxon/files/Saxon-HE/9.3/SaxonHE9-3-0-4N-setup.exe/download,
- rename transform.exe to saxon.exe, add folder with exe to PATH
- create a build dir (i.e. "mkdir android-build")
- run from build dir ( replace $SOURCE_PATH):
cmake -DCMAKE_TOOLCHAIN_FILE=$SOURCE_PATH/Toolchain/arm-eabi.cmake -DCACHE_SIZE="(20*1024*1024)" -DAVOID_FLOAT=1 -DANDROID_PERMISSIONS="CAMERA" $SOURCE_PATH -G "MinGW Makefiles"
- run MinGW32-make
- run MinGW32-make apkg
- install Navit-debug.apk (in <build path>/navit/android/bin) to your device
- copy navit/android/bin/Navit-debug.apk to your device (i.e. sd-card) and run it from there or
- if debug bridge (adb) is enabled run adb install navit/android/bin/Navit-debug.apk