下載Android 原始碼(高牆之下,只能用映象啦)
按照http://source.android.com上的步驟並不能獲取android原始碼,估計又是被牆了。不過經過研究發現可以從一些映象站點上獲取android原始碼
$ mkdir ~/bin $ PATH=~/bin:$PATH $ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo $ chmod a+x ~/bin/repo $ mkdir WORKING_DIRECTORY $ cd WORKING_DIRECTORY 以上命令不再解釋,很簡單很明白。 Setp 3.從其他映象獲取原始碼下載程式碼出錯
- error: Failed to connect to 2404:6800:4005:c00::52: Network is unreachable while accessing https://android.googlesource.com/mirror/manifest/info/refs
- fatal: HTTP request failed
解決方法
1. 瀏覽器登入https://android.googlesource.com/new-password,並用gmail帳號登入;
2. 點選網頁上的“允許訪問”,得到類似
- machine android.googlesource.com login git-jacky.rg4.net password 1/dkRiGEvvC8o8Pgg-GsM2AbMNS_32-U0Pf0_VWkYogIA
- machine android-review.googlesource.com login git-jacky.rg4.net password 1/dkRiGEvvC8o8Pgg-GsM2AbMNS_32-U0Pf0_VWkYogIA
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-4.0.3_r1
6. repo sync
即可拉下Android原始碼。
官方的說法是:因為訪問基本是匿名的,為了防止連線過多(指內網/虛擬機器),對同一IP地址的連線數做了一定的限制。看來是用gmail帳號進行認證。
這樣的話,在公司網路內或者用虛擬機器下載的話,會經常遇到這問題。
檢視Android原始碼版本
- $ grep PLATFORM_VERSION build/core/version_defaults.mk
- # PLATFORM_VERSION
- # PLATFORM_VERSION_CODENAME
- ifeq "" "$(PLATFORM_VERSION)"
- PLATFORM_VERSION := 4.1.2
- # SDK version the branch is based on and PLATFORM_VERSION_CODENAME holds
- ifeq "" "$(PLATFORM_VERSION_CODENAME)"
- PLATFORM_VERSION_CODENAME := REL
- ifeq "REL" "$(PLATFORM_VERSION_CODENAME)"
- DEFAULT_APP_TARGET_SDK := $(PLATFORM_VERSION_CODENAME)
症狀分析: 在Android原始碼下載時,經常會斷掉,這時,就得重新輸入repo sync,那麼,有沒有一種方法在斷網時自動進行repo sync呢?
解決對策:
vi repo_sync.sh
#!/bin/bash
repo sync
while [ $? -ne 0 ]
do
repo sync
done
ubuntu10.04 amd64 git版本升級,error: Exited sync due to gc errors
- ubuntu10.04出現error:Exited sync due to gc errors解決方法
- error: Exited sync due to gc errors 解決方法
- 原因: repo 升級,不相容GIT 1.7.2 以下的版本。
- 升級git到 1.7.2以及以上的版本, 升級方法
- 增加ppa
- sudo apt-add-repository ppa:git-core/ppa
- sudo apt-get update
- sudo apt-get install git
- 如果本地已經安裝過Git,可以使用升級命令:
- sudo apt-get dist-upgrade