Android Platform Developer's Guide
This section describes how to build the default version of Android. Once you are comfortable with a generic build, then you can begin to modify Android for your own target device.
To do a generic build of android, source build/envsetup.sh, which contains necessary variable and function definitions, as described below.
% cd $TOP
% . build/envsetup.sh
# pick a configuration using choosecombo
% make -j4 PRODUCT-generic-user
You can also replace user with eng for a debug engineering build:
% make -j4 PRODUCT-generic-eng
These Build Variants differ in terms of debug options and packages installed.
Execute % m clean to clean up the binaries you just created. You can also execute % m clobber to get rid of the binaries of all combos. % m clobber is equivalent to removing the //out/ directory where all generated files are stored.
Speeding Up Rebuilds
The binaries of each combo are stored as distinct sub-directories of //out/, making it possible to quickly switch between combos without having to recompile all sources each time.
However, performing a clean rebuild is necessary if the build system doesn't catch changes to environment variables or makefiles. If this happens often, you should define the USE_CCACHE environment variable as shown below:
% export USE_CCACHE=1
Doing so will force the build system to use the ccache compiler cache tool, which reduces recompiling all sources.
ccache binaries are provided in //prebuilt/... and don't need to get installed on your system.
The following error is likely caused by running an outdated version of Java.
device Dex: core UNEXPECTED TOP-LEVEL ERROR:
java.lang.NoSuchMethodError: method java.util.Arrays.hashCode with
signature ([Ljava.lang.Object;)I was not found.
dx is a Java program that uses facilities first made available in Java version 1.5. Check your version of Java by executing % java -version in the shell you use to build. You should see something like:
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)
If you do have Java 1.5 or later and your receive this error, verify that you have properly updated your PATH variable.
To build the kernel base, switch to the device directory (/home/joe/android/device) in order to establish variables and run:
% . build/envsetup.sh
% partner_setup generic
Then switch to the kernel directory /home/joe/android/kernel.
Checking Out a Branch
The default branch is always android. To check out a different branch, execute the following:
% git checkout --track -b android-mydevice origin/android-mydevice
//Branch android-mydevice set up to track remote branch
//Switched to a new branch "android-mydevice"
To simplify code management, give your local branch the same name as the remote branch it is tracking (as illustrated in the snippet above). Switch between branches by executing % git checkout
Find out which branches exist (both locally and remotely) and which one is active (marked with an asterisk) by executing the following:
% git branch -a
To only see local branches, omit the -a flag.
To build the kernel, execute:
% make -j4
When building for a particular product, it's often useful to have minor variations on what is ultimately the final release build. These are the currently-defined build variants:
If you build one flavor and then want to build another, you should run make installclean between the two makes to guarantee that you don't pick up files installed by the previous flavor. make clean will also suffice, but it takes a lot longer.