The Android source compilation environment can be configured in Ubuntu, it is recommended to use the latest 64-bit Ubuntu LTS (Long time Support);
1. Install the JDK. AOSP Main Branch code needs JAVA7, OpenJDK can be used on Ubuntu.
To install the JAVA7 command:
$ sudo apt-get update$ sudo apt-get install OPENJDK-7-JDK
If you have a Java environment installed on your system, you can update it:
$ sudo update-alternatives--config java$ sudo update-alternatives--config javac
If it is an older version of Android source, you can download and install the corresponding Java JDK;
Java6:kitkat
Java5:froyo
2. Install the required packages for compilation
Ubuntu14.04 64-bit (recommended)
$ sudo apt-get install bison g++-multilib git gperf libxml2-utils make python-networkx zlib1g-dev:i386 zip
Ubuntu12.04 64 bits (12.04 does not support the latest version of compilation)
$ sudo apt-get install git gnupg Flex Bison gperf build-essential Zip curl Libc6-dev libncurses5-dev:i386 x11 proto-core-Dev libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 libgl1- Mesa-dev g++-multilib mingw32 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
For more information, please refer to: Google official documentation
Configure Android source to compile the environment in Ubuntu