做爲一個Android程序員,平時多多少少須要瞭解一些Android底層源碼實現,而咱們平時下載的sdk中,源碼只可追溯到Framework層級,沒有C/C++的代碼。今天分享一下我經過鏡像下載Android 7.1.2 r12(更新時最新)的心路歷程,包括中間也遇到一些坑,好了,廢話很少說,讓咱們開始吧。java
清華大學鏡像官網:https://mirrors.tuna.tsinghua.edu.cn/help/AOSP/android
具體步驟以下:git
1.下載repo工具程序員
mkdir ~/bin PATH=~/bin:$PATH curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
由於被牆了,因此以上步驟會出現沒法鏈接相關錯誤,因此須要把https://android.googlesource.com/
所有使用 https://aosp.tuna.tsinghua.edu.cn/
代替。具體以下:api
mkdir ~/bin PATH=~/bin:$PATH Git clone https://aosp.tuna.tsinghua.edu.cn/android/git-repo.git //將git-repo中的repo文件拷貝到bin目錄 cp git-repo/repo ~/bin/ //打開ropo文件並REPO_URL作以下修改 REPO_URL = ‘https://aosp.tuna.tsinghua.edu.cn/android/git-repo’
2.創建工做目錄:app
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
3.初始化repo:curl
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
4.下載所須要的Android版本工具
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest -b android-7.1.2 r12
5.同步源代碼樹google
repo sync
注:之後都只需使用repo sync同步便可。url
若是你們有什麼好的意見或建議,歡迎關注個人公衆號「Coding小僧」進行留言,謝謝!
若是你有好的文章須要和廣大網友分享,歡迎投稿,謝謝!