Android原生态下载错误解决方法

Android ICS 官方的下载地址是:http://source.android.com/source/downloading.html,用repo进行同步,具体的可以直接看链接,但是目前总会出现类似下面的错误:

1. Exception in thread Thread-3: 
2. Traceback (most recent call last): 
3.   File "/usr/lib/python2.6/threading.py", line 532, in __bootstrap_inner 
4.   self.run() 
5.   File "/usr/lib/python2.6/threading.py", line 484, in run 
6.   self.__target(*self.__args, **self.__kwargs) 
7.   File "/home/haili/android-4.0.4_r1.2/.repo/repo/subcmds/sync.py", line 200, in _FetchHelper 
8.   clone_bundle=not opt.no_clone_bundle) 
9.   File "/home/haili/android-4.0.4_r1.2/.repo/repo/project.py", line 978, in Sync_NetworkHalf 
10.   and self._ApplyCloneBundle(initial=is_new, quiet=quiet): 
11.   File "/home/haili/android-4.0.4_r1.2/.repo/repo/project.py", line 1519, in _ApplyCloneBundle 
12.   exist_dst = self._FetchBundle(bundle_url, bundle_tmp, bundle_dst, quiet) 
13.   File "/home/haili/android-4.0.4_r1.2/.repo/repo/project.py", line 1583, in _FetchBundle 
14.   raise DownloadError('%s: %s ' % (req.get_host(), str(e))) 
15. DownloadError: android.googlesource.com: <urlopen error [Errno 110] Connection timed out>   
16. ... 

该错误看上去很奇怪,感觉像是python的问题,但是已经按照网上要求装了,最后报time out,qing yu建议换个时间段下下看,但是尝试过了很多次都无果,最后又看了下官方的文档介绍,发现有下面一句话:

Using authentication

By default, access to the Android source code is anonymous. To protect the servers against excessive usage, each IP address is associated with a quota.

When sharing an IP address with other users (e.g. when accessing the source repositories from beyond a NAT firewall), the quotas can trigger even for regular usage patterns (e.g. if many users sync new clients from the same IP address within a short period).

In that case, it is possible to use authenticated access, which then uses a separate quota for each user, regardless of the IP address.

The first step is to create a password from the password generator and to save it in ~/.netrc according to the instructions on that page.

The second step is to force authenticated access, by using the following manifest URI: https://android.googlesource.com/a/platform/manifest. Notice how the /a/ directory prefix triggers mandatory authentication. You can convert an existing client to use mandatory authentication with the following command:

$ repo init -u https://android.googlesource.com/a/platform/manifest

意思大体是:因为访问基本是匿名的,为了防止连接过多,对同一IP地址的连接数做了一定的限制。看来是用gmail帐号进行认证。

(*)因此,首先登录https://android.googlesource.com/new-password,使用gmail账户登录,然后点击网页上的“允许访问”,得到类似下面的信息:

[plain] view plaincopy
1. machine android.googlesource.com login git-<userName>.gmail.com password <password> 
2. machine android-review.googlesource.com login git-<userName>.gmail.com password <password> 
 

把上面那段信息(<userName>和<password>用自己得到的真实信息)追加到~/.netrc文件结尾

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

后面按照官方的步骤就可以拉代码了。

在此附上官方的方法:

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

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

3、
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY

4、
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.4_r1.2  (注意:参考上面的(*)和(**))


5、
$ repo sync

posted @ 2013-03-21 09:03  linuxkid  阅读(398)  评论(0编辑  收藏  举报