安裝Git
下載repo
mkdir ~/bin
PATH=~/bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
下載源碼
使用鏡像下載
由于所有代碼都是從隱藏的 .repo 目錄中 checkout 出來的,所以我們只保留了 .repo 目錄,下載后解壓 再 repo sync 一遍即可得到完整的目錄。
使用方法如下:
wget -c https://mirrors.tuna.tsinghua.edu.cn/aosp-monthly/aosp-latest.tar # 下載初始化包
tar xf aosp-latest.tar
cd AOSP # 解壓得到的 AOSP 工程目錄
# 這時 ls 的話什么也看不到,因為只有一個隱藏的 .repo 目錄
repo sync # 正常同步一遍即可得到完整目錄
# 或 repo sync -l 僅checkout代碼
傳統(tǒng)下載方式
創(chuàng)建源碼目錄
mkdir Android11-r22
cd Android11-r22
repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r22
repo sync -c
如何選擇分支:https://source.android.com/setup/start/build-numbers#source-code-tags-and-builds
因為google網(wǎng)站無法正常訪問,需更改源為清華的
修改:.repo/manifests.git/config
將
url = https://android.googlesource.com/platform/manifest
改為
url = https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest
或者修改git config
git config --global url.https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/.insteadof https://android.googlesource.com