< Android 4.3 源代码下载 > Android repo sync 源代码附常见问题解决方法

来源:互联网 发布:矩阵的协方差怎么求 编辑:程序博客网 时间:2024/05/23 18:30

首先参考 Android 官网上关于 sync 源代码的描述:

http://source.android.com/source/downloading.html

To install Repo:

  1. Make sure you have a bin/ directory in your home directory and that it is included in your path:

    $ mkdir ~/bin$ PATH=~/bin:$PATH
  2. Download the Repo tool and ensure that it is executable:

    $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo$ chmod a+x ~/bin/repo
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
就是为了用 curl 下载 repo python 脚本,可以直接在firefox 上测试能否打开这个网站https://dl-ssl.google.com/dl/googlesource/git-repo/repo

如果这个网址打不开的话,可以按照下面的方法解决:

1) Ubuntu 12.04 $ sudo apt-get install miredo miredo-server 

2)  修改 /etc/hosts 文件

这下面这个网址上可以看到Google 整理的ipv6-hosts http://code.google.com/p/ipv6-hosts/

这里,我用的是香港的,http://code.google.com/p/ipv6-hosts/source/browse/hosts ,把所有的hosts 地址附加到你的/etc/hosts 文件中就行了。

当然,你也可以ping 以下 新加坡  http://code.google.com/p/ipv6-hosts/source/browse/hosts.sin , 或是美国的http://code.google.com/p/ipv6-hosts/source/browse/hosts.sjc ,

哪一个网络最快就可以用哪一个。

【在用repo sync Android 源代码的时候,有人的网络可能不需要任何修改就可以。使用家里网络的一般要方便一点,公司网络一般麻烦】

设置完这两步,再试试

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo$ chmod a+x ~/bin/repo


接下来就是 下载 repo 完整的client 用于 Sync 代码

$ mkdir WORKING_DIRECTORY$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest
这里建议直接就用master 就行,不用 -b branch/tag , sync master 之后可以自己checkout 出想用的branch, 比较灵活。


如果你使用公司网络,或是在自己家里有两台电脑在sync 一般执行 repo init 就会出现如下问题:

  1. error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/manifest/info/refs  
  2. fatal: HTTP request failed  
  3. error: The requested URL returned error: 406 while accessing https://android.googlesource.com/platform/manifest/info/refs  
  4. fatal: HTTP request failed 
参考 http://www.rosoo.net/a/201302/16504.html 解决这个问题。


接下来就可以执行 repo sync 同步代码了, 不过在同步的过程中大部分网络还是容易出现问题,所以强烈建议使用 下载脚本,写个死循环重复repo sync,知道 sync 成功为止。

参考 http://www.rosoo.net/a/201302/16503.html

    #!/bin/bash       echo "======start repo sync======"       repo sync -j 16    while [ $? == 1 ]; do       echo "======sync failed, re-sync again======"       sleep 3       repo sync -j 16    done   

repo 支持断点续传,因此每次 re-sync 也不是重新下载,因此不用担心,同时,如果发现卡在某个地方不动了,可以随时 Ctrl + C ,这样就不会耽误太多等待时间。

当你看到开始 checkout 的时候就是 git 仓库 sync 完毕的时候了。

其实 repo 就是 300多个 git 仓库的封装工具,同时管理这300 多个git 仓库,当然你也可以直接操作某个 project 的git 仓库。


repo forall -c git checkout aosp/master
repo forall -p -v bootable/recovery/ -c git branch -a

使用repo 管理你的工程还是很方便的。

注意 checkout 时的错误,有的话,注意重新checkout 以下那个project ,最好强制 -f

repo forall project_dir -c git checkout -f aosp/master


本文参考了以下文章,感谢 !

http://blog.csdn.net/yanzi1225627/article/details/9255457

http://zhidao.baidu.com/question/453915178.html

原创粉丝点击