Android 4.4 Source Code compilation process

Source: Internet
Author: User

Android source after downloading the directory as follows:

The size of the entire code is: 25.559GB.

First, build the system

The following instructions for building the Android source tree apply to all code branches, including the master branch.

1. Select a branch

Some requirements for building a system are determined by the version of the source code that will be selected for compilation. Use the URL http://source.android.com/source/build-numbers.html to view a list of all current Android branches. You can choose to download and build the latest source code (known as "Master"), in which case, when initializing the library, you can omit the specified branch parameters directly.

Once you have selected the branch, follow the commands below to build the system. The basic build command sequence is as follows:

2. Initialization

Use the envsetup.sh script to initialize the environment, and note that you can use "." Characters to replace the source. As follows:

[Plain]View Plaincopy
    1. $source build/envsetup.sh


Or

[Plain]View Plaincopy
    1. $ . build/envsetup.sh


and the latter short format is used more frequently in files.

3. Select a target

Use the lunch command to choose which target to build. The exact configuration can be passed as a parameter to the command, as follows:

[Plain]View Plaincopy
    1. $lunch Aosp_arm-eng

The above example specifies to build a completed emulator with all of its debugging enabled, after entering the command,

If there are no parameters behind the lunch, then a directory will allow you to choose the prompt. As follows:

All of the build targets are in the form of Build-buildtype, where build is the code name that represents a particular feature combination, as shown in the partial list:

and BuildType as follows:

For better information on building and running on real hardware, refer to: http://source.android.com/source/building-devices.html

4. Building Code

Using make to build everything, GNU makes can handle parallel tasks by using the-JN parameter. Here N, according to the hardware of the computer used to specify the number of cores, General n is specified as the CPU core 1 to twice times. For example, on a dual-5520 machine (2 CPUs, each CPU4 core, 2 threads per core), the fastest build is to use Make-j16 or make-j32.

[Plain]View Plaincopy
    1. $make-j4

5. Running

You can run the built Android system on the emulator, flash to the device, and notice that the target has been built using the lunch command. It is best not to run the target of the build on another different target.

1) simulate an Android device

Once the compilation is complete, set the environment variables and add the following variables to the Ete/profile:

Then, run the emulator by typing the following command:

[Plain]View Plaincopy
    1. $emulator


2) Flash to the device

For Flash to the device, you need to use FastBoot, which is included in your path after a successful build. At boot time, either manually place the device into FastBoot mode with the appropriate combination of keys. or enter FastBoot mode by entering the following command from the shell

[Plain]View Plaincopy
    1. $ADB reboot bootloader


Once the device is in FastBoot mode, run:

[Plain]View Plaincopy
    1. $fastboot flashall-w

The-w option is used to erase the/data portion of the device, which is useful for the first flash of a particular device, otherwise it is not required.

For more information about building and running on real hardware, see: http://source.android.com/source/building-devices.html


Second, the use of CCache

CCache is a compiler ccache for C and C + +. can make building faster. At the root of the source code, do the following:

[Plain]View Plaincopy
    1. $export use_ccache=1
    2. $export Ccache_dir=/<path_of_your_choice>/.ccache
    3. $prebuilts/misc/linux-x86/ccache/ccache-m 50G

The recommended cache size is 50-100g

You can use the following actions to see the size of the CCache used

[Plain]View Plaincopy
    1. $watch-n1-d Prebuilts/misc/linux-x86/ccache/ccache-s

If you use an ice Cream Sandwich (4.0.x) or older version, you need to use prebuilts instead of Prebuilts/misc

Problems during the run:

Problem: Qemu:could not load initrd ' ramdisk.img '

Workaround:

Enter the directory where the Ramdisk.img is located (~/my_android/out/target/product/generic/) and run the following command

[Plain]View Plaincopy
    1. chmod 777-r *



And when running emulator, add the full path name, as follows:

[Plain]View Plaincopy
    1. emulator-kernel/my_android/prebuilts/qemu-kernel/arm/kernel-qemu-armv7-sysdir/my_android/out/target/product/ generic/-system System.img-data Userdata.img-ramdisk/my_android/out/target/product/generic/ramdisk.img-skindir skins/-skin hvga-partition-size 768

Where skins is copied from the SDK directory.

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.