Compile the Android 4.4.2 source code
In the previous article, I shared with you the process of downloading the android 4.4.2 source code in the sky (see the whole process of downloading the android4.4.2 source code (with the downloaded source code). Now I will write down the compilation notes.
Installing the JDK
The master branch of Android in the Android Open Source Project (AOSP) requires Java 7. On Ubuntu, use OpenJDK.
Java 7: For the latest version of Android
$ sudo apt-get update$ sudo apt-get install openjdk-7-jdk
Optionally, update the default Java version by running:
$ sudo update-alternatives --config java$ sudo update-alternatives --config javac
However, during my actual compilation process, I still prompted that sun's jdk should be used for compilation (I wonder if this is because my step is incorrect ?). So the following describes how to download and install sun jdk. 1. Download the sun jdk 1.6.
Here, we will download the jdk 1.6 64-bit version (32-bit or 64-bit depending on your system) and go to emerge SE Development Kit 6u45, then, click "Accept License Agreement" on the newly opened page. after accept, select the jdk-6u45-linux-x64.bin to download. If you have not logged on, the system will go to the logon page and enter your username and password registered on the Oracle website.
I have uploaded the downloaded jdk-6u45-linux-x64.bin to my online drive at http://dd.ma/sseswlns. If you do not want to log on to the oracle website, you can access it through the above short address.
2. Install sun jdk 1.6. If you have not installed jdk on ubuntu, create the java directory. You can create it under/usr/local. Here, my JDK is basically installed in/usr/lib/jvm, So I copied the downloaded file directly to this directory. The command is as follows:
Cd ~ /Download/sudo cp jdk-6u45-linux-x64.bin/usr/lib/jvm
Next, decompress the binfile.
$ sudo chmod +x jdk-6u45-linux-x64.bin$ sudo ./jdk-6u45-linux-x64.bin$ sudo rm jdk-6u45-linux-x64.bin
3. Configure SUN JDK3.1 and configure JDK environment variables to add JDK environment variables. The values to be added are similar to those in windows. Here I use the user's environment variable. Edit it first ~ /. Bashrc:
vi ~/.bashrc
Shift + G to the bottom of the file. Add or edit three environment variables: JAVA_HOME, CLASSPATH, PATH, as follows (I have configured a JRE_HOME here ):
JAVA_HOME=/usr/lib/jvm/jdk1.6.0_45JRE_HOME=$JAVA_HOME/jreCLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/libPATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME/lib:$JAVA_HOME
Then run source ~ /. Make bashrc take effect.
3. 2. Configure the JDK location of UBUNTU. Run the following command:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_45/bin/java 300sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_45/bin/javac 300sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_45/bin/javaws 300
3.3 configure the default JDK of UBUNTU and run the following commands respectively, and then select the sun jdk to be installed.
sudo update-alternatives --config java sudo update-alternatives --config javac sudo update-alternatives --config javaws
Take the first command as an example. After running the command, it lists all the java programs you have installed and configured, and asks which one you want to select. As shown below.
$ Sudo update-alternatives -- config java has three candidates to replace java (/usr/bin/java ). Select path priority status defaults 0/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 automatic mode 1/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 Manual mode 2/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1051 manual mode * 3/usr/lib/jvm/jdk1.6.0 _ 45/bin/java 300 manual mode to be maintained the current value is [*]. Press enter, or enter the selected number:
Select the sun jdk we have installed. Next, run java-version to check whether it is sun's jdk 1.6. If not, restart your computer.
4. Compile the Android source code. After the JDK is installed, continue the compilation.
msdx@msdx-ubuntu:~/code/442$ source build/envsetup.sh
Then execute:
msdx@msdx-ubuntu:~/code/442$ lunch
Select the version you want to compile. Here I chose the first one, because I just want to compile a small module of the source code. Run the following command:
msdx@msdx-ubuntu:~/code/442$ m
Then you can wait for the compilation to complete.