因为之前的虚拟机奔溃,再次下载时回报DownloadError: android.googlesource.com: <urlopen error [Errno 104] Connection reset by peer>错误,
DownloadError: android.googlesource.com: <urlopen error [Errno 110] Connection timed out>
经过官网查找原因,发现
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.
也就是说同一IP再次下载会失效,
解决方案如下:
1. 浏览器登录https://android.googlesource.com/new-password,并用gmail帐号(就是你初始化repo时填写的gmail邮箱)登录;
2. 点击网页上的“允许访问”,
进入后copy “Staying Authenticated”下边灰色部分的内容:
1 machine android.googlesource.com login git...............
2 machine android-review.googlesource.com login git...................
3.将copy的内容写进~/.netrc文件中,如果你的/home下没有这个文件的话,可以创建一个
4. repo init -u https://android.googlesource.com/a/platform/manifest (注意该URL中多了一个/a)
5. repo sync
现在就可以下载Android源码。