Android源代碼下載
第一次下載android源碼,難免會遇到些小白問題,so,做下記錄。
英文好的話可以直接看這裏:http://source.android.com/source/downloading.html
一、新建你的源代碼的文件夾:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
二、下載工具repo
$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo $ chmod a+x ~/bin/repo
可能遇到問題:無法下載或是無法下載
解決方法:更換下載地址
$ curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
或:$ curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ./repo //獲取repo
三、找個空間比較大的地方放將要下的源碼,
$ mkdir YOU——WORK_NAME $ cd YOUR——WORK_NAME
四、repo init初始化代碼倉庫
$ ./repo init -u https://android.googlesource.com/platform/manifest
五、下載源代碼
$ repo sync
可能遇到問題:鏈接不成功或下載中斷
解決方法:
在.repo目錄下的manifest.xml裏找到fetch屬性
改成
fetch="git://Android.git.linaro.org/"或fetch= "https://android.googlesource.com/"(據說後者下載速度快,未驗證)
中斷問題可以寫哥腳本,如下:
創建腳本download.sh
#!/bin/bash
echo "=========start repo sync=============="
./repo sync
while [ $? == 1 ]; do
echo "======sync failed, re-sync again======"
sleep 3
./repo sync
done
記得chomd a+x download.sh讓其可以運行。提示:下載時間有點長,最後晚上設置下電腦下載。