解决下载android源码时出现的无法连接问题

http://developer.android.com/sdk/index.html

http://source.android.com/source/

 

1.curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

执行curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo会出现如下错误:

root@ubuntu:~ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

--2013-04-21 04:30:42-- https://dl-ssl.google.com/dl/googlesource/git-repo/repo

Resolving dl-ssl.google.com... 74.125.128.91, 74.125.128.93, 74.125.128.136, ...

Connecting to dl-ssl.google.com|74.125.128.91|:443... failed: Connection refused.

Connecting to dl-ssl.google.com|74.125.128.93|:443... failed: Connection timed out.

Connecting to dl-ssl.google.com|74.125.128.136|:443... failed: Connection timed out.

Connecting to dl-ssl.google.com|74.125.128.190|:443... failed: Connection timed out.

Connecting to dl-ssl.google.com|2404:6800:4005:c00::5d|:443... failed: Network is unreachable.

 

2.在执行repo sync下载android的时候出现如下信息:

error: Failed to connect to 2404:6800:4008:c00::52: Network is unreachable while accessinghttps://android.googlesource.com/platform/manifest/info/refs?service=git-upload-pack
fatal: HTTP request failed
error: Failed to connect to 2404:6800:4008:c00::52: Network is unreachable while accessinghttps://android.googlesource.com/platform/manifest/info/refs?service=git-upload-pack
fatal: HTTP request failed

curl: (7) Failed to connect to 2404:6800:4008:c00::52: Network is unreachable

curl: (7) Failed to connect to 2404:6800:4008:c00::52: Network is unreachable

curl: (7) Failed to connect to 2404:6800:4008:c00::52: Network is unreachable

curl: (7) Failed to connect to 2404:6800:4008:c00::52: Network is unreachable
error: Failed to connect to 2404:6800:4008:c00::52: Network is unreachable while accessinghttps://android.googlesource.com/platform/bootable/bootloader/legacy/info/refs?service=git-upload-pack
fatal: HTTP request failed
error: Failed to connect to 2404:6800:4008:c00::52: Network is unreachable while accessinghttps://android.googlesource.com/platform/bootable/recovery/info/refs?service=git-upload-pack
fatal: HTTP request failed

解决方法

1. 浏览器登录https://android.googlesource.com/new-password,并用gmail帐号登录(去谷歌注册);

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

1 machine android.googlesource.com login git-.gmail.com password   2 machine android-review.googlesource.com login git-.gmail.com password

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

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

5. repo init -u https://android.googlesource.com/a/platform/manifest -b android-2.3.3_r1

6. repo sync

即可拉下Android源码。

官方的说法是:因为访问基本是匿名的,为了防止连接过多(指内网/虚拟机),对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。

这样的话,在公司网络内或者用虚拟机下载的话,会经常遇到这问题。

源码官网指导网址:http://source.android.com/source/downloading.html

你可能感兴趣的:(Android)