Android source code explanation 01: Download Android source code

Source: Internet
Author: User
Tags git commands

The android Source Code contains many things, such as embedded applications in the Android system.Program(For example, photo taking, calculator, calendar, dial, etc.)Source codeThe sources of various Android SDK tools (such as ADB and emulator)CodeAndroid ndk source code, Hardware Abstraction Layer HAL source code, and so on.

The blog series of "android source code parsing" will record what I learned from the android source code.

 

1. Install the GIT Tool

The android source code is managed using the GIT version control tool. Run the following command to install the GIT tool on the Ubuntu operating system:

 
Root @ Ubuntu :~ # Apt-GetInstallGit-core GnuPG

The Error 404 Not found was encountered during installation, as shown in 1.

Figure 1 [404 Not found] Error

The reason is that gitsoftware resources are not found on http://us.archive.ubuntu.com/ubuntu/source. The solution is to change to a valid source. The specific method is as follows:

Select the "ubuntu Software Center" option under the "Applications" menu, and select the "software sources" option under the "edit" menu in the pop-up "ubuntu Software Center" dialog box, the "software sources" dialog box 2 is displayed.

Figure 2 "software sources" dialog box

In the "software sources" dialog box shown in 2, select the "other" option in "Download from. The "chose a download server" dialog box shown in Figure 3 is displayed.

Figure 3 "chose a download server" dialog box

In the "choose a download server" dialog box shown in 3, select "select best server". The system will automatically find the best source and click "choose server.

After the source is changed, git can be installed smoothly.

 

2. Download the repo Tool

Before downloading the android source code, you need to download a repo tool, which encapsulates the GIT commands required to download the android source code.

The repo tool is downloaded and installed as follows:

 
Root @ Ubuntu :~ #WgetHttps://Dl-ssl.google.com/dl/googlesource/git-repo/repoRoot @ Ubuntu :~ #ChmodA +X repo root @ Ubuntu:~ #MVRepo/bin/

Through the above operations, we downloaded the repo tool, modified its permissions to executable, and finally put the repo tool in the/bin directory.

 

3. Download the android source code

Now, we can create an empty directory for storing the downloaded Android source code. Here, my storage directory is/home/menlsh/androidsrc.

Run the following command in the androidsrc directory to download the android source code. Here I chose to download the source code of android4.0.

 
Root @ Ubuntu:/home/menlsh/androidsrc # repo init-u https://Android.googlesource.com/platform/manifest-B android-4.0.1_r1Root @ Ubuntu:/home/menlsh/androidsrc # RepoSync

Next, there is a long wait time. Repo supports resumable storage. If network interruption occurs during the download process, you only need to execute the repo sync command again to continue the download.

During the download process, no file content is displayed in the androidsrc directory. After the download is complete, the message "done" shown in 4 is displayed.

Figure 4 download completed

At the same time, the android source code directory structure shown in Figure 5 is displayed in the androidsrc directory.

Figure 5 Android source code directory structure

Now, the android source code is downloaded.

 

4. Android source code directory structure Parsing

As shown in figure 5, the android source code directory contains many subdirectories. The meanings of these subdirectories are described below.

(1) ABI: Application binary Interface)

(2) bionic: C/C ++ Runtime Library

(3) bootable: used to load and start Android programs, including Bootloader and recovery.

(4) Build: a tool used to compile the android source code and create files such as system. IMG and ramdisk. IMG.

(5) CTS: A Tool for compatibility testing

(6) Dalvik: source code of the Dalvik Virtual Machine

(7) Development: some development and testing tools

(8) device: Device-related code

(9) docs: documents and tools related to the android source code project

(10) External: source code of the extended Tool

(11) frameworks: source code of the android framework layer (that is, the source code of the android SDK)

(12) Hardware: hardware layer interface and Library (HAL source code)

(13) libcore: Java core library

(14) ndk: source code of ndk

(15) packages: source code of the application released with the Android system (such as photos and calculators)

(16) prebuilt: the tool used before Android compilation on various platforms

(17) SDK: tools used in the development environment (such as ddms and draw9patch)

(18) system: basic Android system

(19) makefile: Compile the script

In these directories, device, frameworks, hardware, and packages will be my key learning objects and will be the main content of this series of blog posts.

 

 

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.