Mobile/Fennec/Android/Detailed build instructions
Detailed build instructions
Mac OS X
Preparation
First, you need to install XCode and a few supplementary build tools via a package manager. To do this, follow steps 1 and 2 of the Mac OS X Build Prerequisites page. Once you have completed steps 1 and 2, come back here and continue with the instructions below.
Step by step instructions
Install ant
You'll to install the ant package, which you can do with HomeBrew:
brew install ant
Install Android NDK
Download and extract the Android NDK. The NDKs with 64-bit toolchains (x86_64) are recommended because linking Firefox requires a lot of memory. The supported NDK version right now is r8e. Installing newer versions will break your builds (see bug 951968 and bug 994859 for some examples).
curl -O http://dl.google.com/android/ndk/android-ndk-r8e-darwin-x86_64.tar.bz2 tar -xjf android-ndk-r8e-darwin-x86_64.tar.bz2
NOTE: there have been reports that r8c does not work on OS X before 10.7.0 (i.e. on Snow Leopard); you may need to try an older (or newer!) NDK version if you are running Snow Leopard. link and link. At time of updating this doc (17-may-2013), we have not tried r8e on OSX before 10.7.0.
Install Android SDK
You should just install the latest Android SDK, since we set the API level in our manifest files. The SDK download will take a while, so make sure you have a decent internet connection and go get coffee (or maybe lunch).
You will need to install support for Android API version 23. Run the Android SDK GUI updater:
./adt-bundle-mac/sdk/tools/android
You will probably want to add the SDK's "tools", "build-tools", and "platform-tools" directories to the PATH environment variable in your shell, so that you can run adb and other tools easily. For example, if you installed the SDK in $HOME, you could add the following line to the end of your .bashrc:
export PATH=$PATH:$HOME/adt-bundle-mac/sdk/tools:$HOME/adt-bundle-mac/sdk/build-tools:$HOME/adt-bundle-mac/sdk/platform-tools
Linux
Preparation
If you're using a 64-bit Linux, you'll need to install 32 bit libs to allow the toolchain binaries to run. Otherwise you may get a "bash: file not found" error when trying to use any of the SDK/NDK tools.
# http://stackoverflow.com/questions/13571145/android-adb-not-found sudo apt-get install libc6-i386 lib32stdc++6 lib32gcc1 lib32ncurses5 lib32z1
or for Fedora
yum install glibc-devel.i686 ncurses-libs-devel.i686 libstdc++-devel.i686 zlib-devel.i686
On older Debian/Ubuntu systems you can run
# On recent Debian or Ubuntu you may need to run "sudo dpkg --add-architecture i386" first. # For details see: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697924 sudo apt-get install ia32-libs
If you later on encounter errors during the build process, check the detailed instructions in the following section: in particular, verify that all required packages are installed running Android SDK GUI updated.
Step by step installation
This section describes in greater detail all the dependencies and requirements of getting a working build environment on Linux.
Install Java
First install JDK 7 or 8. Either the Sun JDK or OpenJDK is acceptable. If you're on Ubuntu (pre-11.10), you'll need to enable the partners repo to get it. Java 6 or earlier won't work.
# Ubuntu pre-11.10 sudo apt-get update sudo apt-get install sun-java7-jdk sudo update-java-alternatives -s java-7-sun
# Ubuntu 11.10 and after # Use this PPA, the instructions are on the page: # https://launchpad.net/~webupd8team/+archive/java
If you're on Ubuntu 64-bit, you'll also want to install ia32-libs at this point (things like adb won't work until you do):
apt-get install -y ia32-libs
On Ubuntu 13.10 and later, ia32-libs is no longer in the standard repository. Add the following line to the end of your /etc/apt/sources.list file (or add it through synaptic)
deb http://archive.ubuntu.com/ubuntu/ raring main restricted universe multiverse
apt-get update apt-get install -y ia32-libs
Install ant
ant 1.8.0 or later is required to build parts of Gecko View:
sudo apt-get install ant
Install Gecko Requirements
Then install the usual stuff needed for a firefox build.
sudo apt-get install mercurial ccache sudo apt-get build-dep firefox
Install Android NDK
Download and extract the Android NDK. The automated builders currently use version r8e. r8d does NOT work (see bug 825968). For a 64-bit OS:
wget https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86_64.tar.bz2 tar -xjf android-ndk-r8e-linux-x86_64.tar.bz2
For a 32-bit OS:
wget https://dl.google.com/android/ndk/android-ndk-r8e-linux-x86.tar.bz2 tar -xjf android-ndk-r8e-linux-x86.tar.bz2
Install Android SDK
You should install the latest Android SDK (not the big download button that says "Eclipse ADT", just get the SDK). The SDK download will take a while, make sure you have a decent internet connection and go get coffee, or maybe lunch.
After extracting the SDK, ensure it's up to date with these commands:
./adt-bundle-linux/sdk/tools/android update sdk -u ./adt-bundle-linux/sdk/tools/android update adb
Or to update manually, run the Android SDK GUI updater:
./adt-bundle-linux/sdk/tools/android
If you get an error like this while trying to run the Android SDK Manager:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-gtk-3550 or swt-gtk in swt.library.path, java.library.path or the jar file
then make sure your /tmp directory is executable:
sudo mount -o remount,exec /tmp
You will probably want to add the SDK's "tools", "build-tools", and "platform-tools" directories to the PATH environment variable in your shell, so that you can run adb and other tools easily. For example, if you installed the SDK in $HOME/opt, you could add the following line to the end of your .bashrc:
export PATH=$PATH:$HOME/opt/adt-bundle-linux/sdk/tools:$HOME/opt/adt-bundle-linux/sdk/build-tools:$HOME/opt/adt-bundle-linux/sdk/platform-tools
Windows
It is not currently possible to build Fennec directly on Windows, but it is possible to build inside a virtual machine.
A fresh install of Ubuntu in a virtual machine can be configured to build Fennec: just follow the regular bootstrap or Linux directions. Do assigned plenty of RAM and CPU to the VM: assigning less than 8G RAM for the build, or assigning more RAM to the VM than the host system can support, may result in very very slow builds. If your virtualization software supports connecting USB devices to a VM, it should be possible to install directly to device from the build VM.
Other
Other build environments has some notes on a few other environment variations, so take a look at that as well if you have an environment or configuration that deviates from the norm.