一、下載安裝repo 工具html
mkdir ~/bin PATH=~/bin:$PATH curl https://storage-googleapis.proxy.ustclug.org/git-repo-downloads/repo > ~/bin/repo chmod a+x ~/bin/repo
二、創建一個放android源碼的目錄,名字隨意android
mkdir android_sourcecode cd android_sourcecode
三、初始化repo庫git
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest
四、若是須要下載某個特定的android版本,只需經過 -b指定版本號就行api
repo init -u git://mirrors.ustc.edu.cn/aosp/platform/manifest -b android-7.1.1_r22
五、repo庫初始化後,就能夠直接下載指定版本的android源碼,也能夠經過指定下載路徑,來下載源碼中某一個模塊curl
#下載repo庫裏全部的android源碼 repo sync #指定下載路徑,下載某個模塊代碼 repo sync packages/providers/ContactsProvider
repo sync命令後接的path,在執行repo init目錄下(此處即android _sourcecode)有個.repo文件夾,能夠經過ide
.repo/manifest.xml 查看各個模塊的路徑,而後經過repo sycn path來下載學習最新的android源碼,查看googel大神們寫的代碼工具
若是之後android源碼更新了,只需改變步驟4中-b後指定的路徑,Android全部版本列表學習