Android source code structure

Source: Internet
Author: User
Tags how to use git

Introduction

When using the Andriod SDK for application development, we need to debug the source code. It may need to go to an Android API function for tracking and debugging. However, if the SDK of the target version is not associated with the source code of the corresponding version, you will be prompted that the source code cannot be found.

Figure: the Android Source Code cannot be found.

  

We all know that the Android system is an open-source project that can be downloaded to the source code on the Internet. You can find various methods to download the source code, such as using Git and Repo. The android source code download URL is http://android.git.kernel.org /. I will not go into details about how to use Git to download the android source code, because there are many online methods. Here is a reference link for downloading the Android source code on the Windows platform.

If you are a beginner like me, I believe that after reading the above article, you will know how to use Git to download the android source code. However, looking at the http://android.git.kernel.org/site under the various directories and files, I believe you will be as dumb as I do not know what the file under that directory corresponds to the code, it is more difficult to find what you need. So here we will introduce you to the structure of the android source code. If you find any errors in this article, please make sure that you can easily smash bricks!

Figure: http://android.git.kernel.org/complex files

  

Before learning about the Android source code structure, familiarize yourself with the Android system architecture! The Android system architecture is divided into four layers: Linux operating system and driver layer, local framework and Java Runtime Environment, Java framework, and Java application layer. The details of each layer are skipped here.

Figure: Android system architecture

  

Understanding Android source code structure

Android Code project is divided into three parts, open the http://android.git.kernel.org/after seeing, is the root directory of the android source code. (Suggestion: After you open this website, learn the following content)

  • Core Project: build the foundation of the Android system in each folder in the root directory.
  • Extended projects: use the extended functions of other open-source projects in the External Folder.
  • Package: Provides Android applications and services in the package folder.

1. Android Core Project

The core project of Android includes support for basic operation of Android system and compilation system of Android system. The project content is as follows:

Android Core Project
Project name Project Description
Bionic [Build system] C runtime support: libc, libm, libdl, dynamic linker
Bootloader/legacy Bootloader reference code (kernel loader, run before kernel running)
Build [Build system] Build System
Dalvik Dalvik Virtual Machine
Delelopment High-level Development and debugging tools
Framework/base Android core framework Library
Framework/policies/base Framework Configuration Policy
Hardware/libhardware Hardware Abstraction Layer Library
Hardware/ril Radio Interface Layer)
Kernel Linux Kernel
Prebuilt [Pre-compiled kernel] binary support for Linux and Mac OS Compilation
System/core Minimal startup Environment
System/extras Underlying debugging and check tools

 

  

In addition to the projects listed in the above table, there are other projects, but most of them are the 2nd-level source code of the Android system.

2. Android Extension Project

Android extension projects are included in the external Folder and are some open-source projects that have been modified to adapt to the Android system. Some projects run on the host and some on the target machine. Because there are too many extension projects, I will not list them one by one. If you are interested in shoes, you can collect some information and learn about them.

  

3. Java package in Android

The Java package in Android is the Content at Layer 4th of the Android system architecture. It consists of Application and Content Providers. The inputmethods directory is the Content of the input method.

Applications in the package/apps directory include: AlarmClock, Browser, Calculator, Calendar AR, Camera, Contacts, E-mail, GoogleSearch, HTML Viewer, IM, Launcher, mms, Music, PackageInstaller, Phone, Settings, SoundRecorder, Stk, Sync, Updater, VoiceDialer.

  

Content Providers are in the package/providers directory. They include: CalendarProvider, ContactsProvider, DownloadProvider, DrmProvider, metrics, metrics, ImProvider, MediaProvider, metrics, metrics, and TelephonyProvider.

  

Download as needed

If you only need one or several files, you can use the following git command:

Git clone git: // android.git.kernel.org/project code path

(For example, git clone git: // android.git.kernel.org/platform/packages/providers/DrmProvider.git)

The target Download address is the current directory of the current git command line.

Download the Android SDK source code for each version

We provide you with a method to download the SDK source code of different versions in Windows. I have also found other methods on the Internet, but they are all copied and Paste.

Or refer to another blog post: html "> Use git to download the android. jar Source Code

1. Download and install Git;

2. Create a new file frameworks. This folder is used to store the directory of the Android SDK source code you want to download.

3. Start the Git bash command line and enter the commandGit clone git: // android.git.kernel.org/platform/frameworks/base.git frameworksDownload all the files and folders in the base folder on the android.git.kernel.org site to the local frameworks folder;

4. In the Git command line environment, use the cd command to gradually enter the frameworks/base folder;

5. Use"Git tag"Command to display the names of all Android source code projects;

  

6. Find the name and version of the source code you need and use the command"Git checkout android-1.5r4"Switch to the emulator version;

7. Copy all files under frameworks/base/core/java to the "android-sdk-windowsplatformsandroid-3sources" folder under your SDK directory.

Note: each time you switch the Simulator version, git automatically downloads the source code of the corresponding version from the website to the frameworks/base/folder, and then copies the files in the folderCorresponding versionIn the SDK directory.

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.