"Android Deep Exploration Volume One" reading notes four

Source: Internet
Author: User
Tags create directory

Download, compile and test Android source code

1. Configure the Android source code download environment

Before downloading, you must perform some command configuration environment on Linux terminal.

Create the directory where the script files are stored "mkdir ~/bin" "Path=~/bin: $PATH"; download repo script file "Curl address > ~/bin/repo" "chmod a+x ~/bin/repo"; Create directory for Android source code "mkdir android_source" "CD Android_source"; initialize "repo init-u address";

2. Start downloading Android source code

The "Repo sync" download takes up bandwidth and can be 4h or longer, depending on the performance of the machine.

Android Source code directory:


3. Download the specified project:

Method 1. " Repo syncplatfrom/project Name ".

Where to get relevant information through file Manifest.xml: Each line represents a project, path represents the project path, and name indicates the project name. You can also know the current source code-related information.

Method 2. " git clone address < project name >.

4. Compiling Android source code

Before compiling, go to the source code root directory.

4.1. Initialize the compilation environment "source build/envsetup.sh" The envsetup.sh script file is used to initialize the compile command, which defines some shell functions. "MM" and "MMM" can compile the project specified in the Android source code.

4.2. Select target: "Lunch Full-eng" is selected for all mobile devices, the Android emulator is active, and all debugging options are turned on. The default "Full-eng", you can select other by ordinal.

4.3. Compile Android source code "make", 4 cores available "Make-j4". The time, after the successful compilation, the Android source code root will generate an out directory, all the compiled target files are in this directory.

The 4.4.out folder directory structure is as follows:

out/

--CaseCheck.txt

--Casecheck.txt

--Host

--Common

--Linux-x86/darwin-x86

--Target (this directory is debug/target if Target_strip_module=false is defined at compile time)

--Common

--Product

The main two directories are host and Target, which represents the tools generated on the host (x86), which represents the content that the target machine (modulo thinks ARMv5) is running.

The structure of the host directory is as follows:

out/host/

--Common

--obj (Java library)

--linux-x86/darwin-x86

--Bin (binary program)

--Framework (Java Library, *.jar file)

--Lib (Shared library *.so)

--obj (intermediate generated target file)

The host directory is some of the tools used on hosts, some are binaries, and some are Java programs.

The structure of the target directory is as follows:

out/target/

--Common

--R (resource file)

--Docs

--obj (target file)

--Apps (contains the target of Java application generation, each of which corresponds to one of the subdirectories, will be combined with each application's original file to build the APK package for Android apps)

--Java_libraries (contains a library of JAVA, each of which corresponds to one subdirectory)

--Product

--generic

--Android-info.txt

--Clean_steps.mk

--Data (the file system in which it resides)

--obj

--Apps (contains various Java applications, corresponds to Common/obj/apps, but has already been APK package)

--Shared_libraries (store all dynamic libraries)

--Static_libraries (store all static libraries)

--ramdisk.img (root file system image of the memory disk)

--Root

--Symbols

-System (storing the main file system)

--System.img (image of File system)

--userdata-qemu.img (data file used by simulator)

--USERDATA.IMG (data content image)

5. Publish your apk as an Android built-in program

APK is the zip format, odex format file is separate apk and Classes.dex file get. Copy the project directory to the Android source code directory/packagea/apps, perform "MM" compilation at the terminal, and after success, generate the. apk and. odex files in the System/app directory.

6. Test the system.img file with the simulator

A new program is added and a new system.img file will be generated. Under the <android source code directory >/out/target/product/generic directory, execute "mkyaffs2image system system.img" to generate a new system.img file.

Add the <android SDK root directory >/tools directory in path, open the AVD, and execute "EMULATOR-AVD myavd-system system.img-data userdata.img", The Android emulator will start with the new data. The program is embedded in the Android system and cannot be uninstalled routinely. Unless you delete the. apk and. odex files, regenerate the system.img file to launch the Android emulator.

"Android Deep Exploration Volume One" reading notes four

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.