Compiling Android source code (AOSP)

Source: Internet
Author: User
Tags root access

Step 1: According to the official documents, download the source code, configure the environment, and execute the corresponding commands. It is best to follow the official hardware and system configuration build.
build version is 6.0, source directory is /home/koder/android-source-20151229   Requirements:
    • The source of the download is very large, estimated to have 30,40g around. Plus build, it's best to free up 100+ space.
    • According to the official Mac OS or Ubuntu Lts (14.04) X64, it is Ubuntu Lts (14.04) 64 bits.
    • Hardware problem: Insufficient memory, see the end of the article 1.
There is a note that the document says: Lunch Aosp_arm-eng this is to build an IMG that adapts to the emulator and allows debug.   Aosp_arm-eng means target Or build Configuration, the format is: Build-buildtypeAosp_arm is build. If you want to build different devices or emulator IMG, you will have different values. Click here for an introduction. Where arm is called code name ENG is buildtype: Use
BuildType
User limited access; Suited for production
Userdebug Like "user" but with root access and debuggability; Preferred for debugging
Eng Development configuration with additional debugging tools

Source: https://source.android.com/source/building.html
Some examples of target are these:
Device Code name Build Configuration
Nexus 6P Angler Aosp_angler-userdebug
Nexus 5X Bullhead Aosp_bullhead-userdebug
Nexus 6 Shamu Aosp_shamu-userdebug
Nexus Player Fugu Aosp_fugu-userdebug
Nexus 9 Volantis (Flounder) Aosp_flounder-userdebug
Nexus 5 (Gsm/lte) Hammerhead Aosp_hammerhead-userdebug
Nexus 7 (Wi-Fi) Razor (Flo) Aosp_flo-userdebug
Nexus 7 (Mobile) Razorg (Deb) Aosp_deb-userdebug
Nexus 10 Mantaray (Manta) Full_manta-userdebug
Nexus 4 Occam (Mako) Full_mako-userdebug
Nexus 7 (Wi-Fi) Nakasi (Grouper) Full_grouper-userdebug
Nexus 7 (Mobile) Nakasig (Tilapia) Full_tilapia-userdebug
Galaxy Nexus (gsm/hspa+) Yakju (Maguro) Full_maguro-userdebug
Galaxy Nexus (Verizon) Mysid (Toro) Aosp_toro-userdebug
Galaxy Nexus (experimental) MYSIDSPR (Toroplus) Aosp_toroplus-userdebug
PandaBoard (archived) Panda Aosp_panda-userdebug
Motorola Xoom (U.S. Wi-Fi) Wingray Full_wingray-userdebug
Nexus S Soju (Crespo) Full_crespo-userdebug
Nexus S 4G Sojus (CRESPO4G) Full_crespo4g-userdebug

Don't use the 4.1.1 on a Nexus 7 that is originally sold with 4.1.2 or newer.

Source: https://source.android.com/source/running.html

Step 2: After successful make success.
The system system files are generated under directory/home/koder/android-source-20151229/out/target/product/generic, including System.img, Ramdisk.img,userdata.img and so on.   It then runs, because the build is emulator img, so it runs the virtual machine. The official document says that the environment variable will be set automatically, but when the emulator is executed, there is no command, so you need to find the emulator directory yourself. Emulator inPrebuilts/android-emulator, Prebuilts directory is officially provided, download the source code has been build good tools and libraries, including kernel is also under this, so if you want to build kernel, look here. Off-topic, go back to emulator, switch to emulator directory, run: ./emulator \ -sysdir ${ANDROID_PRODUCT_OUT} \ -system ${ANDROID_PRODUCT_OUT}/system.img \ -ramdisk ${ANDROID_PRODUCT_OUT}/ramdisk.img \ -data ${android_product_out}/userdata. IMG \ -kernel /< Span class= "PLN" >home/koder/android< Span class= "pun" >-source-20151229/prebuilts/qemu-kernel/arm/kernel- qemu-armv7 \ -skindir /home/koder/android-source-20151229/sdk/emulator/skins \ -memory 2048 \ -partition-size 2048 \ -skin WVGA800 \ -scale 0.7Emulator command: http://developer.android.com/tools/help/emulator.html to change the corresponding directory on their own good. The personal environment variables are: JAVA_HOME=/home/koder/Documents/jdk1.8.0_65 PATH=$JAVA_HOME/bin:$PATH CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar ANDROID_HOME=/home/koder/Documents/android-sdk-linux android_build_out_host=/home< Span class= "pun" >/koder/android-source-20151229/out /host/linux- x86/bin ANDROID_PRODUCT_OUT=/home/koder/android-source-20151229/out/target/product/generic PATH=$ANDROID_HOME:$ANDROID_BUILD_OUT_HOST:$PATH export JAVA_HOME PATH CLASSPATH ANDROID_PRODUCT_OUT
It's OK to be here.
 
problems encountered during the build process:1. Tip: Increasing heap size. Is that the heap size of the Java virtual machine is not enough, add the environment variable: export _JAVA_OPTIONS=-Xmx8192m
the size of the assignment looks at your own machine. However, even if this is set up, sometimes it does not work, because the machine itself may be insufficient hardware memory, there is no 8G so much good. Because of their own machine is 8G, and run on the virtual machine, only allocated to 4G of space, so the process of build, memory problems stuck themselves for a long time, and the official said, it is best to have 16g ram above, almost give up. Finally think of a way to increase swap memory. As for how to increase swap memory, refer to here. their direct swap increased by 16G, because it was 8G, so it is best to 24G. sigh, Unix "Everything is file" of the great, hardware is not enough, software to fill, hehe ~ ~ ~ Solve this memory problem, on the smooth build out.    

Other than that:

1. View Cccache:watch-n1-d prebuilts/misc/linux-x86/ccache/ccache-s
 

Compiling Android source code (AOSP)

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.