1. 接上一篇,我们找到google服务器地址并且修改了host后, 就要用此地址下载android源码啦, 开始折腾前先确认一下,否则白折腾。
打开网址, http://www.apkbus.com/android-78127-1-1.html, 从里边找一个单独的仓库clone一下,看看是否能下载下来。
比如: git clone https://android.googlesource.com/device/common.git
2. 下载repo
用官方的网址下载repo
curl http://android.googlesource.com/repo >~bin/repo
如果无法下载,则用另一个吧,这是另外一个git服务器的android源码的repo文件。 操作如下
$ curl "http://php.webtutor.pl/en/wp-content/uploads/2011/09/repo" > ./repo //获取repo
$ chmod a+x repo
$ PATH= ~/bin:$PATH
3. repo init
下载master分支:
repo init -u https://android.googlesource.com/platform/manifest
建立mirror:
repo init -u https://android.googlesource.com/platform/manifest --mirror
下载指定分支:
repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r3
当然,你可以下载指定分支的mirror, 方法同上。
repo init -u https://android.googlesource.com/platform/manifest -b android-5.1.0_r3 --mirror
4. repo sync
开始漫长的下载啦: repo sync -j4
如果发生如下错误:
fatal: '../platform/abi/cpp.git' does not appear to be a git repository”
则可以修改以下文件:
.repo目录下的manifest.xml文件
找到fetch属性,在我的文件中显示fetch="..",将fetch修改为fetch="https://android.googlesource.com/",保存并退出;
再重新 repo sync
5. 等待下载完成吧
中间可能会发生错误, 可以写个脚本循环调用 repo sync, 自己从网上查找。
(以下错误我也碰到了,但没有理它,直接再手动打repo sync即可继续下载)
如果报错误异常为
DownloadError: android.googlesource.com: urlopen error 110] Connection timed out
解决方法
1. 浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;
2. 点击网页上的“允许访问”,得到类似
machine android.googlesource.com login git-userName.gmail.com password password ;
machine android-review.googlesource.com login git-userName.gmail.com password password
3. 把上面那段信息追加到~/.netrc文件结尾(请检查当前用户的权限, 如果不存在此文件则自己新建一个);
参考 : http://llll123cccc.blog.163.com/blog/static/3165864201275933110/
6. 下一篇将讲一下,如何构建本地的android镜像, 包括repo.git的建立。
我之前也写过两篇文章,但还是感觉太繁琐了,可以先参考下, 等我再弄完一遍后, 就再重新写一篇.
http://zzqhost.com/?post=71
http://zzqhost.com/?post=70