參考文檔:解決下載Android源碼時遇到的 download error
我下載和編譯環境
ubuntu 12.04 64位 lenovo thinkpad i3 2G
最近要做 android 的瀏覽器外掛程式 要用到 android 的源碼 參與編譯(不是指 framework 層源碼)
按照 google 的官網設定會出現在下載的時候產生錯誤 從而不能下載
之前Android的代碼是在Linux kernel(android.git.kernel.org)管理,被Kernel踢出來之後,Android源碼現在直接由Google(android.googlesource.com)管理。
用repo/git下載源碼時,執行
1 $ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.3_r1
會報錯誤 異常為
1 DownloadError: android.googlesource.com: <urlopen error [Errno 110] Connection timed out>
解決方案
1. 瀏覽器登入https://android.googlesource.com/new-password,並用gmail帳號登入;
2. 點擊網頁上的“允許訪問”,得到類似
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>
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帳號進行認證。
這樣的話,在公司網路內或者用虛擬機器下載的話,會經常遇到這問題。