Android源码目录置于Google的Git仓库。本文指导你下载用于下载源码的manifest文件。
第一步:
大陆用户首先需要设置网络,保证能够连接到google网站。
第二步:安装repo工具:
通过curl命令即可下载repo工具。
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
第三步:初始化git仓库
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest
第四步:下载android源代码
$ repo sync
注意事项:
由于下载过程中容易出现网络问题而中断,为了保持连续下载,可以使用shell脚本反复尝试下载。
-j选项用于指定下载线程数量。
echo "======= start repo sync ======="
repo sync -j 5
while [ $? == 1 ]; do
echo "====== sync failed! re-sync again ====="
sleep 3
repo sync -j 5
done