Compiling Android 4.4.2 Source code

Source: Internet
Author: User
Tags java se

In the previous article, and you share in the Chinese download Android 4.4.2 source code process (see download android4.4.2 source of the entire process (with the downloaded source)), now write down the compiled notes.


Although in Android Doc, there are mentions can be compiled with open JDK, see: Https://source.android.com/source/initializing.html, described as follows:

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

But in my actual compilation process, I still hint that I should use Sun's JDK to compile (I don't know if my steps are wrong?). )。 So let's start with the download and install Sun jdk. 1. Download Sun JDK 1.6

Here are the examples of the JDK 1.6 64-bit version (specifically 32-bit or 64-bit view of your own system), into http://www.oracle.com/technetwork/java/javasebusiness/downloads/ java-archive-downloads-javase6-419409.html, select Java SE development Kit 6u45, and then click Accept License Agreement on the newly opened page. Once accepted, select "Jdk-6u45-linux-x64.bin" to download. If you are not logged in, the system will first go to the login page and enter the username and password you registered with the Oracle website.

I have uploaded the downloaded jdk-6u45-linux-x64.bin in My network, the address is as follows: Http://dd.ma/sSesWlnS. You do not want to log on to Oracle's Web site, which can be accessed through the above short address.

2. Install SUN JDK 1.6 If you do not have a JDK installed on Ubuntu, then create a Java directory, the location of your own decision, you can create under/usr/local. Here my JDK is basically installed in/USR/LIB/JVM, so I copy the downloaded file directly to this, the command is as follows:
CD ~/download/sudo cp JDK-6U45-LINUX-X64.BIN/USR/LIB/JVM

Next, unzip the bin file.
$ sudo chmod +x jdk-6u45-linux-x64.bin$ sudo./jdk-6u45-linux-x64.bin$ sudo rm jdk-6u45-linux-x64.bin

3. Configure the environment variables of the JDK3.1 configuration jdk to add the JDK environment variables, the values to add are much the same as under Windows. Here I use the user's environment variables, first edit ~/.BASHRC:
VI ~/.BASHRC
Press SHIFT + G to the bottom of the file. Add or edit three environment variables: java_home, CLASSPATH, PATH, as follows (I've configured more than one 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 the source ~/.BASHRC to make it effective.
3.2. Configure the JDK location for 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 for Ubuntu to run the following command separately, and then select the installed Sun JDK.
sudo update-alternatives--config java sudo update-alternatives--config javac sudo update-alternatives--config javaws

Take the first command as an example, and after running it will list all the Java you have installed and configured, and ask which one you want to choose. as shown below.
$ sudo update-alternatives--config Java has 3 candidates that can be used to replace Java (providing/usr/bin/java).  Select the       path                                          priority  State------------------------------------------------------------  0            /usr/lib/ Jvm/java-6-openjdk-amd64/jre/bin/java   1061      Auto 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       Manual mode to maintain the current value [*] press ENTER, or type the selected number:

Choose the Sun JDK we installed separately. Next run java-version to see if it is Sun's JDK 1.6, and if not, you may need to restart your computer.
4. After compiling the Android source after installing the JDK, continue with our compilation work.
[Email protected]:~/code/442$ Source build/envsetup.sh
Then execute:
[Email protected]:~/code/442$ Lunch

Then 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. Then execute the command:
[Email protected]:~/code/442$ m

You can then wait for the compilation to complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.