Android source code compilation process and focus

Source: Internet
Author: User

1. Install 64-bit Linux

2. install Java 6
$ Sudo add-Apt-repository "Deb http://archive.canonical.com/lucid partner"
$ Sudo add-Apt-repository "Deb-Src http://archive.canonical.com/ubuntu lucid partner"
$ Sudo apt-Get update
$ Sudo apt-Get install sun-java6-jdk

3. install Java 5
$ Sudo add-Apt-repository "Deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
$ Sudo add-Apt-repository "Deb http://archive.ubuntu.com/ubuntu dapper-Updates main Multiverse"
$ Sudo apt-Get update
$ Sudo apt-Get install sun-java5-jdk

4. Switch Java version
Switch to java6:
$ Sudo Update-Java-alternatives-s Java-6-sun
Switch to java5:
$ Sudo Update-Java-alternatives-s Java-1.5.0-sun

5. Install and compile the library required by Android
$ Sudo apt-Get install Git-core GnuPG flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g ++-multilib libc6-dev-i386 lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev

6. Install SVN
$ Sudo apt-Get install Subversion

7. Install Vim
$ Sudo apt-Get install Vim

8. First, go to the source code directory.

9. grant permissions to all files in the source code directory

# Chmod-r 777/home/user Note: Set the permissions of the entire/home/user directory and its files and subdirectories to rwxrwxrwx.

10. Execute source build/envsetup. Sh in the root directory of the source code.

11. Execute the choosecombo command and select as prompted in the displayed selection.

12. Execute make SDK to compile the source code (about two or three hours, depending on the CPU performance)

13. After compilation, the entire size will be increased by several GB, and several folders and files will appear in the out folder. It indicates that the compilation is successful.

14. Create a project:

Then add some permissions to the project:

Android: shareduserid = "android. uid. System"

<Uses-Permission Android: Name = "android. Permission. install_packages"> </uses-Permission>

<Uses-Permission Android: Name = "android. Permission. delete_packages"> </uses-Permission>

<Uses-Permission Android: Name = "android. Permission. clear_app_user_data"> </uses-Permission>

<Uses-Permission Android: Name = "android. Permission. clear_app_cache"> </uses-Permission>

 

Statement in the program:

Runtime.getruntime(cmd.exe C ("PM install-R" + "directory structure for program installation ");

 

Then, put Android. mk in the root directory of the project, edit Android. mk, add local_certificate: = platform, and put the project in the packages/apps/directory of the source code.

 

Note:

1. the Java class does not contain Chinese characters. The Chinese characters must be written in string. xml.

2. Do not overwrite the mark.

 

15: compile the project (in the jdk1.5 environment)

Run the following command in the android source code directory:
$. Build/envsetup. Sh
$ Mmm packages/apps/contacts/** directory of the Project **

 

If the compilation is successful, you will

Find the generated apk in the/out/target/product/generic/system/APP/directory.

Note: QQ technology exchange group: add one if you are interested in 108614806.

 

 

Related Article

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.