我下載和編譯環境
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帳號進行認證。
這樣的話,在公司網絡內或者用虛擬機下載的話,會經常遇到這問題。
源碼官網指導網址: http://source.android.com/source/downloading.html
歡迎各位同學加入 android 技術群 155595043
個人微博: http://weibo.com/338226333
有問題可以微博商討
