User:Blassey/Notes/Android NDK5

From MozillaWiki
Jump to navigation Jump to search

Setup a Build Environment

Quick Script

 sudo add-apt-repository ppa:ferramroberto/java 
 sudo apt-get update
 sudo apt-get install sun-java6-jdk mercurial ccache
 sudo apt-get build-dep firefox
 wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
 tar -xjf android-ndk-r6-linux-x86.tar.bz2
 wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
 tar -xzf android-sdk_r12-linux_x86.tgz
 # go get lunch, this will take a while
 ./android-sdk-linux_x86/tools/android update sdk -u
 ./android-sdk-linux_x86/tools/android update adb

Explained

Install Java

First install the Sun Java jdk6, which the Android SDK depends on If you're on Ubuntu 11.04, you'll need to use an addtional repo (ppa) as its not available in the partners repo yet. Others report success using the Maverick partners repo to get it.

 sudo add-apt-repository ppa:ferramroberto/java 
 sudo apt-get update
 sudo apt-get install sun-java6-jdk

Install Gecko Requirements

Then install the usual stuff needed for a firefox build, you probably already have it

 sudo apt-get install mercurial ccache
 sudo apt-get build-dep firefox

Install Android NDK

Download and extract the NDK. NDK revs 4, 5 and 6 have been tested and confirmed to work.

 wget http://dl.google.com/android/ndk/android-ndk-r6-linux-x86.tar.bz2
 tar -xjf android-ndk-r6-linux-x86.tar.bz2

Install Android SDK

You should just install the latest sdk, we set the API level in our manifest files. The sdk download will take a while, make sure you have a decent internet connection and go get coffee, or maybe lunch.

 wget http://dl.google.com/android/android-sdk_r12-linux_x86.tgz
 tar -xzf android-sdk_r12-linux_x86.tgz
 ./android-sdk-linux_x86/tools/android update sdk -u
 ./android-sdk-linux_x86/tools/android update adb


Build

You build as you normally would (make -f client.mk), just with a differnt mozconfig

mozconfig

Here's an example mozconfig that should get you building, modify it to meet your needs.

 # Add the correct paths here:
 ac_add_options --with-android-ndk="$HOME/android-ndk-r6"
 ac_add_options --with-android-sdk="$HOME/android-sdk-linux_x86/platforms/android-8"
 ac_add_options --with-android-version=5
 ac_add_options --with-android-tools="$HOME/android-sdk-linux_x86/tools"
 ac_add_options --with-android-toolchain="$HOME/android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86"
 ac_add_options --with-android-platform="$HOME/android-ndk-r6/platforms/android-5/arch-arm"
 # android options
 ac_add_options --enable-application=mobile
 ac_add_options --target=arm-linux-androideabi
 ac_add_options --with-endian=little
 ac_add_options --with-ccache
 
 mk_add_options MOZ_OBJDIR=./objdir-droid
 mk_add_options MOZ_MAKE_FLAGS="-j9 -s"