1. 程式人生 > >【Android原始碼】如何下載Android原始碼

【Android原始碼】如何下載Android原始碼

對於下載原始碼這種操作,官方給的說明確實也是很詳細。但是奈何GFW。所以用國內的源跑得比什麼都快。網上也有很多教程,但是這些感覺是copy——因為它們都比不上國內源的網站上給的操作說明。

國內有哪些Android的映象源

2. 清華大學

從上面的兩個連結直接點進去便是幫助文件,跟著幫助文件一步一步走就OK了。但是我還是想偷一下懶。。。也許有一天我並不想點這兩個連結,那就看下面吧。

按照 Google 官方教程 https://source.android.com/source/downloading.html
https://android.googlesource.com/platform/manifest


替換為 git://mirrors.ustc.edu.cn/aosp/platform/manifest

具體做法摘錄如下(以防牆抽風):

1. 首先下載 repo 工具。

mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

如果上述 URL 不可訪問,可以用下面的:
curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo


chmod a+x ~/bin/repo

2. 然後建立一個工作目錄(名字任意)

mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY

3. 初始化倉庫:

repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest

如果提示無法連線到gerrit.googlesource.com,可以編輯 ~/bin/repo,把 REPO_URL 一行替換成下面的:
REPO_URL = 'https://gerrit-googlesource.proxy.ustclug.org/git-repo'


如果需要某個特定的 Android 版本(Android 版本列表):
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-4.0.1_r1

4. 同步原始碼樹(以後只需執行這條命令來同步):

repo sync

5. 已有倉庫如何改用科大源

如果您已經從官方同步了 AOSP 倉庫,現在希望使用科大的 AOSP 倉庫,請修改.repo/manifests.git/config,將
url = https://android.googlesource.com/platform/manifest
修改成
url = git://mirrors.ustc.edu.cn/aosp/platform/manifest
即可。