android source code 下载 可以通过google官方或者第三方镜像下载 ,步骤基本一样
一 google 官网
Downloading the Source
The Android source tree is located in a Git repository hosted by Google. The Git repository includes metadata for the Android source, including those related to changes to the source and the date they were made. This document describes how to download the source tree for a specific Android code-line.
Installing Repo
Repo is a tool that makes it easier to work with Git in the context of Android. For more information about Repo, see the Developingsection.
To install Repo:
-
Make sure you have a bin/ directory in your home directory and that it is included in your path:
$ 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
Initializing a Repo client
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
-
Configure git 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.
$ git config --global user.name "Your Name" $ git config --global user.email "you@example.com"
-
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
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.
Downloading the Android Source Tree
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.
二 , 第三方AOSP
选择清华AOSP镜像
网站 :http://aosp.tuna.tsinghua.edu.cn/android/
过程摘录
(参考 https://lug.ustc.edu.cn/wiki/mirrors/help/aosp 编写)
下载 repo 工具:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
建立工作目录:
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
初始化仓库:
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
# 或 repo init -u git://aosp.tuna.tsinghua.edu.cn/aosp/platform/manifest
## 如果提示无法连接到 gerrit.googlesource.com,可以编辑 ~/bin/repo,把 REPO_URL 一行替换成下面的:
REPO_URL = 'https://gerrit-google.tuna.tsinghua.edu.cn/git-repo'
如果需要某个特定的 Android 版本(列表):
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-4.0.1_r1
同步源码树(以后只需执行这条命令来同步):
repo sync