Android源码下载

来源:互联网 发布:医院网络客服工资高吗 编辑:程序博客网 时间:2024/06/05 20:49

Android源码下载

最近下载android源码遇到了些问题,参考了网上一些解决办法,终于可以下了,总结如下:

1、下载repo

$ mkdir ~/bin
$ PATH=~/bin:$PATH

$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo$ chmod a+x ~/bin/repo

2、下载源码

$ mkdir WORKING_DIRECTORY$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1 
$ repo sync
 

但是在下载过程经常遇到以下错误:

错误1:

fatal: Cannot get https://gerrit.googlesource.com/git-repo/clone.bundle
fatal: error [Errno 101] Network is unreachable

错误2:

error: Failed to connect to 2404:6800:4008:c01::52: Network is unreachable while accessing https://android.googlesource.com/platform/frameworks/compile/libbcc/info/refs  
fatal: HTTP request failed  

错误3:

error: The requested URL returned error: 403 while accessing https://android.googlesource.com/a/platform/build/info/refs

 

解决方法:

 

1. 浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录;

    此步骤可能需要$翻墙$

 

2. 点击网页上的“允许访问”,得到类似


3. 把上面2那段信息追加到~/.netrc文件结尾(请检查当前用户的权限, 如果不存在此文件则自己新建一个);

 

4. 下载地址的URI更改为https://android.googlesource.com/a/platform/manifest(中间加上了“/a”)。

 

5. repo init -uhttps://android.googlesource.com/a/platform/manifest-b android-4.0.1_r1

  执行时需要输入用户名,此用户是步骤2得到的。

 

6. repo sync

 

如果以上方法不行,可以尝试

在.repo目录下的manifest.xml里找到fetch属性
改成
fetch= "git://Android.git.linaro.org/ "

 

为了防止在下载过程中出现网络异常导致无法继续下载,用下面这个脚本sync源码比较安全:

#!/bin/bash 

echo"======start repo sync======" 

repo sync -j2

while [ $? == 1]; do

echo"======sync failed, re-sync again======" 

sleep 3

repo sync -j2

done



0 0
原创粉丝点击