One Android operating system source code compilation experience

Source: Internet
Author: User
Tags android sdk manager

I recently compiled the source code of the Android operating system based on the information I saw. The result is successful, but the process is tortuous. The first thing I want to talk about is the prerequisites. This is very important, at first, I took a lot of detours because I didn't meet the prerequisites.
1, get the latest Android source code from the http://source.android.com compilation information, this is not the following compilation must be used,
However, it is indeed more accurate in all compilation materials related to the Android operating system source code.

2. Use Ubuntu Linux 12.04 lts. If you want to try it according to what I wrote, select this option, which can save your time;

3. Install related software packages

Click (here) to fold or open

  1. Sudo apt-Get install Git-core
  2. Sudo apt-Get install GnuPG
  3. Sudo apt-Get install flex
  4. Sudo apt-Get install bison
  5. Sudo apt-Get install gperf
  6. Sudo apt-Get install libsdl-Dev
  7. Sudo apt-Get install libesd0-dev
  8. Sudo apt-Get install build-essential
  9. Sudo apt-Get install zip
  10. Sudo apt-Get install curl
  11. Sudo apt-Get install libncurses5-dev
  12. Sudo apt-Get install zlib1g-dev

When I wrote this article, the above installation was successful, but you will not be able to ensure it is successful, because there may be some software sources
It has changed. If this happens, you can check the latest solution on the Internet based on the keywords prompted during installation.
Is to update the software source, the following is a general method to update the software source:
[Backup Software source]
Sudo CP/etc/APT/sources. LIST/etc/APT/sources. List. Backup
(If you want to restore the original software source, run: sudo CP/etc/APT/sources. List. Backup/etc/APT/sources. List)
[Edit software source]
Sudo gedit/etc/APT/sources. List
Add and save the updated software source at the end of the file and exit.
[Update software source]
Sudo apt-Get update

4. install Java JDK
(1) If JDK and JRE have been installed in the system, uninstall them first (APT-Get remove JDK software name)
(2) Update the JDK software source
Sudo add-Apt-repository "Deb http://us.archive.ubuntu.com/ubuntu/ hard Multiverse"
Sudo apt-Get update
(3) install Java jdk6
Sudo apt-Get install sun-java6-jre sun-java6-plugin sun-java6-fonts sun-java6-jdk
(4) install Java jdk5
Sudo apt-Get install sun-java5-jdk
(5) modify the link of javadoc

Click (here) to fold or open

  1. CD/etc/alternatives
  2. Sudo RM javadoc.1.gz
  3. Sudo ln-S/usr/lib/JVM/Java-1.5.0-sun/man/Man1/javadoc.1.gz javadoc.1.gz
  4. Sudo RM javadoc
  5. Sudo ln-S/usr/lib/JVM/Java-1.5.0-sun/bin/javadoc


5. Set Environment Variables
Sudo gedit ~ /. Bashrc
Add at the end of the file

Click (here) to fold or open

  1. Java_home =/usr/lib/JVM/Java-6-sun
  2. Jre_home =$ {java_home}/JRE
  3. Export android_java_home = $ java_home
  4. Export classpath =. :$ {java_home}/lib: $ jre_home/lib: $ classpath
  5. Export java_path =$ {java_home}/bin: $ {jre_home}/bin
  6. Export jre_path = $ java_path
  7. Export java_home;
  8. Export jre_home;
  9. Export classpath;
  10. Home_lib = ~ /Bin/
  11. Export path =$ {path }:$ {java_path }:$ {jre_path }:: {home_bin };
  12. # Echo $ path

Run: sudo source ~ /. Bashrc
Suggestion: restart ubuntu.

6. Install the compilation tool
[Solve the problem that an android official website cannot be downloaded first]
Sudo gedit/etc/hosts
Append a sentence at the end of the file: 74.125.237.1 dl-ssl.google.com

Cd ~
Mkdir Bin
Run the following command on http://source.android.com/source/downloading.html
Curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo> ~ /Bin/Repo
Chmod A + x ~ /Bin/Repo

7. Install gcc4.4

Click (here) to fold or open

  1. Sudo apt-Get install gcc-4.4
  2. Sudo apt-Get install g ++-4.4
  3. Sudo apt-Get install g ++-4.4-multilib
  4. Sudo Rm-RF/usr/bin/GCC/usr/bin/g ++
  5. Sudo ln-S/usr/bin/gcc-4.4/usr/bin/GCC
  6. Sudo ln-S/usr/bin/g ++-4.4/usr/bin/g ++


8. Install Python
Sudo apt-Get install Python

9. Download the android source code

Click (here) to fold or open

  1. Mkdir ~ /Work/android-cts-2.2_r8
  2. Cd ~ /Work/android-cts-2.2_r8
  3. Repo init-u https://android.googlesource.com/platform/manifest-B android-cts-2.2_r8
  4. Repo sync

This is a long process and it is best to do it during a vacation. ,

10. Comment out information about Java version Verification in the source code.
Cd ~ /Work/android-cts-2.2_r8
Gedit./build/CORE/Main. mk

Click (here) to fold or open

  1. # Check for the correct version of Java
  2. # Java_version: = $ (shell Java-Version 2> & 1 | head-N 1 | grep '["] 1 \. 5 [\." $]')
  3. # Ifeq ($ (Strip $ (java_version )),)
  4. # $ (Info ************************************ ************************)
  5. # $ (Info you are attempting to build with the incorrect version)
  6. # $ (Info of Java .)
  7. # $ (Info $ (Space ))
  8. # $ (Info your version is: $ (shell Java-Version 2> & 1 | head-N 1 ).)
  9. # $ (Info the correct version is: 1.5 .)
  10. # $ (Info $ (Space ))
  11. # $ (Info please follow the machine setup instructions)
  12. # $ (Info $ (Space) http://source.android.com/download)
  13. # $ (Info ************************************ ************************)
  14. # $ (Error stop)
  15. # Endif
  16. # Check for the correct version of javac
  17. # Javac_version: = $ (shell javac-Version 2> & 1 | head-N 1 | grep '["] 1 \. 5 [\." $]')
  18. # Ifeq ($ (Strip $ (javac_version )),)
  19. # $ (Info ************************************ ************************)
  20. # $ (Info you are attempting to build with the incorrect version)
  21. # $ (Info of javac .)
  22. # $ (Info $ (Space ))
  23. # $ (Info your version is: $ (shell javac-Version 2> & 1 | head-N 1 ).)
  24. # $ (Info the correct version is: 1.5 .)
  25. # $ (Info $ (Space ))
  26. # $ (Info please follow the machine setup instructions)
  27. # $ (Info $ (Space) http://source.android.com/download)
  28. # $ (Info ************************************ ************************)
  29. # $ (Error stop)
  30. # Endif

11. Last preparation before Compilation

Click (here) to fold or open

  1. Cd ~ /Work/android-cts-2.2_r8
  2. Source./build/envsetup. Sh
  3. Lunch full-Eng

12. Compile source code
After a long preparation, we can finally compile it.

Click (here) to fold or open

  1. Cd ~ /Work/android-cts-2.2_r8
  2. Make

This is also a long process. Please wait patiently during the holidays.

13. Run the compilation command to view the result.
If the above sudo gedit/etc/profile
If the compilation is successful, we can use the virtual machine to check the results.
(1) download the SDK to the android official website, http://developer.android.com/sdk/index.html
(2) decompress the downloaded SDK to the main folder and change it to Android-SDK-Linux.
(3) sudo gedit/etc/profile
Set
Export Path = "$ path :~ /Android-SDK-Linux/tools"
Last file written
(4) sudo gedit ~ /. Profile
Set

Click (here) to fold or open

  1. Export Path = "$ path: $ home/work/android-cts-2.2_r8/out/host/linux-x86/bin"
  2. Android _ product_out = $ home/work/android-cts-2.2_r8/out/target/product/generic
  3. Export android_product_out

The end of the written file.
(5) use the android command to open the android SDK Manager interface and download the SDK platform for installing android2.2.
(6) Finally, you can check the results.

Click (here) to fold or open

  1. Cd ~ /Work/android-cts-2.2_r8/out/target/product/generic
  2. Emulator-image system. IMG-data userdata. IMG-ramdisk. img

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.