转自: http://blog.csdn.net/lsdmx2016/article/details/40822391
根据android.source.com给出的同步代码的方法
repo init -u https://android.googlesource.com/platform/manifest -b android-5.0.0_r2
repo sync
这种方法经过我的测试是成功的,有可能提示 找不到 android-5.0.0_r2,多重复几次 应该可以成功,
因为在 https://android.googlesource.com/platform/manifest/+refs 中可以找到branch: android-5.0.0_r2
同步代码中有可能出现的问题:
1.branch没有找到
可以先到 https://android.googlesource.com/platform/manifest/+refs中查看 你所同步的branch 是否
存在,这个里面的内容是变化的,google有可能会添加/删除branch,比如 之前存在的branch:lollipop-release,
已经不存在了。
2.无法访问gerrit.googlesource.com
user:~/work/android-5.0$ repo init -u https://android.googlesource.com/platform/manifest -b android-5.0.0_r2
fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable
解决方案: 由于大家都知道的原因,我们经常无法访问google站点,与我们init 代码相关的站点有
两个 android.googlesource.com 和 gerrit.googlesource.com,在/etc/hosts 中添加如下两行
74.125.21.98 android.googlesource.com
74.125.21.98 gerrit.googlesource.com
如果上面的ip地址不起作用(将ip地址输入到浏览器地址栏),那么可以去网上查找google网站最新
的hosts IP地址, 或者使用linux命令 nslookup 查询最新IP , 例如终端运行:
nslookup gerrit.googlesource.com
经过我的测试 添加 这两行后 repo init 成功,让后通过 repo sync 同步代码