可以参考http://source.android.com/source/downloading.html
一、安装Repo
1. Make sure you have a bin/ directory in your home directory and that it is included in your path:
在主目录下创建bin目录,并将此目录包含进你的环境变量中
-
$ mkdir ~/bin $ PATH=~/bin:$PATH
-
Download the Repo tool and ensure that it is executable:
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
二、初始化Repo客户端
After installing Repo, set up your client to access the Android source repository:
-
Create an empty directory to hold your working files. If you're using MacOS, this has to be on a case-sensitive filesystem. Give it any name you like:
$ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY
-
Run
repo init
to bring down the latest version of Repo with all its most recent bug fixes. You must specify a URL for the manifest, which specifies where the various repositories included in the Android source will be placed within your working directory.$ repo init -u https://android.googlesource.com/platform/manifest
To check out a branch other than "master", specify it with
-b
. For a list of branches, see Source Code Tags and Builds.$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
-
When prompted, configure Repo with your real name and email address. To use the Gerrit code-review tool, you will need an email address that is connected with a registered Google account. Make sure this is a live address at which you can receive messages. The name that you provide here will show up in attributions for your code submissions.
A successful initialization will end with a message stating that Repo is initialized in your working directory. Your client directory should now contain a .repo
directory where files such as the manifest will be kept.
三、下载源码树
To pull down the Android source tree to your working directory from the repositories as specified in the default manifest, run
$ repo sync
The Android source files will be located in your working directory under their project names. The initial sync operation will take an hour or more to complete. For more about repo sync
and other Repo commands, see the Developing section.