2nd Android source Download and compilation

Source: Internet
Author: User
Tags git commands

Before analyzing the Android source code, you must first learn how to download and compile the system. This chapter will give the reader a complete view of the Android source download process, common problems and processing methods, and from the developer's perspective to understand how to properly compile the Android system (including the original ecosystem and custom equipment).
Later, we will go deep into the analysis of the compilation script on this basis. In the spirit of "discovering" to restore a large and rigorous Android compilation system.

2.1 Android Source Download Guide 2.1.1 version management based on repo and git

Git is a distributed version management system that was originally designed for version control of the Linux kernel. This book tools in the use of Git, the principle of a more detailed analysis of the framework, it is recommended that the reader first read the relevant chapters to understand.
Git is very powerful and fast, and is the tool of choice for many open source projects today. However, Git also has some shortcomings, such as the relative graphical interface of the tool is not so easy to use, the need for internal principles have a certain understanding to be well used, do not support the continuation of the breakpoint and so on.
To do this, Google offers a Python script specifically designed to download the source code for Android, repo.
In the repo environment, the process of version modification and submission is:

    • Create a new branch with repo, which is generally not recommended for operations on the master branch;
    • The developer changes the project document according to the requirements;
    • Use the git add command to temporarily save the changes you have made;
    • Commit the changes to the repository using the git commit command;
    • Use the repo Upload command to commit the modifications to the code server.
      Thus, the repo is slightly different from the GIT process we discussed in the tool, and the difference is mainly in the interaction with the remote service repository, while the local development is still based on the native GIT commands. Below we explain some of repo's common commands, and the reader can also take a closer look at his and git comparisons.
1. Synchronization

Synchronization allows the local code to be consistent with the remote repository in two forms.
If you are synchronizing all of the current items:

$ repo Sync

 
   
  
  1. 或者也可以指定需要同步的某个项目:

$ repo sync [PROJECT1] [PROJECT2] ...

2. Branching operations

The command required to create a branch:

$ repo Start

You can also see how many branches are currently available:

$ repo Branches

Or:

$ git Branch

and switch to the specified branch:

$ git checkout

3. Query operations

Querying the current state

$ repo Status

Query for UNCOMMITTED modifications:

$ Repo diff

4. Version Management operations

Staging file:

$ git add

Submit file:

$ git commit

If you are committing a modified server, you first need to synchronize:

$ repo Sync

Then execute the upload command:

$ repo Upload

2.1.2 Android Source Download process

After understanding the general operation of Repo, this section then analyzes the entire process of Android source download. This is not only the premise of analyzing the principle of Android system, but also makes many novice confused, source download can be used as a beginner to understand the Android system "Hello world."

To be particularly reminded, all of the following steps are done in the Ubuntu operating system (the "#" is followed by the comment content).

1. Download repo

CD ~ #进入home目录
> mkdir bin #创建bin目录用于存放Repo脚本
P AT H = /bIN: Path #将 The bin directory into the system path
Curl Https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/binrepo #curl is a command-line-based file transfer tool that supports MMM-hmm. Very many protocols. Here we use curl to save the repo to the appropriate directory
> chmod a+x ~/bin/repo

Note: Many developers on the internet (mainland China) reflect that the above address is often not successfully accessed. If the reader also has a similar problem, you can try the following:

$ Curl Https://android.googlesource.com/repo > ~/binrepo

2. Repo Configuration

Before you begin to download the source code, you need to make the necessary configuration for the repo.
As shown below:
>



From for notes (Wiz)

2nd Android source Download and compilation

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.