The source download is approximately 8.5GB in size. You will need over 30GB free to complete a single build, and up to 100GB (or more) for a full set of builds.
These instructions apply to Ubuntu LTS (10.04), but most distributions should have the required build tools available like Linux Mint 13, Sabayon X or Arch Linux.
For Gingerbread (2.3.x) and newer versions, including the master branch, a 64-bit environment is required. Older versions can be compiled on 32-bit systems.
Note: It is also possible to build Android in a virtual machine. If you are running Linux in a virtual machine, you will need at least 16GB of RAM/swap and 30GB or more of disk space in order to build the Android tree.
In general you will need:
The Sun JDK is no longer in Ubuntu's main package repository. In order to download it, you need to add the appropriate repository and indicate to the system which JDK should be used.
$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
$ sudo apt-get update
$ sudo apt-get install sun-java6-jdk
You will need a 64-bit version of Ubuntu. Ubuntu 10.04 is recommended. Building using a newer version of Ubuntu is currently only experimentally supported and is not guaranteed to work on branches other than master.
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \ x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \ libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \ libxml2-utils xsltproc
On Ubuntu 10.10:
$ sudo ln -s /usr/lib32/mesa/libGL.so.1 /usr/lib32/mesa/libGL.so
On Ubuntu 11.10:
$ sudo apt-get install libx11-dev:i386
Building on Ubuntu 12.04 is currently only experimentally supported and is not guaranteed to work on branches other than master.
$ sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \ libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \ libgl1-mesa-dev g++-multilib mingw32 openjdk-6-jdk tofrodos \ python-markdown libxml2-utils xsltproc zlib1g-dev:i386 $ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
You can optionally tell the build to use the ccache compilation tool. Ccache acts as a compiler cache that can be used to speed-up rebuilds. This works very well if you do "make clean" often, or if you frequently switch between different build products. Put the following in your .bashrc or equivalent.
$ export USE_CCACHE=1
By default the cache will be stored in ~/.ccache. If your home directory is on NFS or some other non-local filesystem, you will want to specify the directory in your .bashrc as well.
$ export CCACHE_DIR=<path-to-your-cache-directory>
The suggested cache size is 50-100GB. You will need to run the following command once you have downloaded the source code:
prebuilts/misc/linux-x86/ccache/ccache -M 50G
When building Ice Cream Sandwich (4.0.x) or older, ccache is in a different location:
prebuilt/linux-x86/ccache/ccache -M 50G
This setting is stored in the CCACHE_DIR and is persistent.
Guideline created by AOSP project, to see the original please, visit Initializing a Build Environment