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: Download Android. Jar source code using git

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 command git clone git: // android.git.kernel.org/platform/frameworks/base.git frameworks, all files and folders in the base folder on the android.git.kernel.org site will be downloaded 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 the "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 switch to the corresponding version of the simulator (emulator) by running the "Git checkout android-1.5r4" command;

7. Copy all files under frameworks/base/CORE/Java to the "Android-SDK-Windows \ platforms \ Android-3 \ sources" 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, copy the files in the folder to the SDK directory of the corresponding version.

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.