使用repo下載google 的android4.4 源碼
參看http://hi.baidu.com/j_key/item/170505ad9efd0037030a4d5d,根據(jù)自己的下載過程進(jìn)行修改了。
環(huán)境:ubuntu12 64 位。
1.安裝git
sudo apt-get install git-core
2.安裝curl
sudo apt-get install git-core curl
3.安裝repo, 通過curl下載repo
google s是這樣告訴我們的:curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
但是好像是不能訪問
解決方法:
http://code.google.com/p/git-repo/downloads/detail?name=repo-1.12 這個(gè)鏈接提供下載repo!
也可以通過下面命令得到:
curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo
具體的repo版本可以去查看http://code.google.com/p/git-repo/downloads 頁面上的信息,下載那個(gè)版本都行。
4.修改執(zhí)行權(quán)限
chmod a+x ~/bin/repo
5.修改~/bin/repo文件將第五行
問題:
builder56@builder56-desktop:~/google/android_source$ curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (56) Recv failure: 連接被對(duì)端重置
解決方法:修改~/bin/repo文件將第五行
REPO_URL='https://gerrit.googlesource.com/git-repo'
改為
REPO_URL='http://gerrit.googlesource.com/git-repo'
6.然后向PATH中添加bin路徑:
export PATH=$PATH:~/bin
使用$PATH 查看該值,看是否添加成功
7.新建一個(gè)目錄,然后進(jìn)入該目錄。
mkdir source
cd source
8.執(zhí)行repo init 創(chuàng)建倉庫
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.4_r1 //下載android-2.3.4_r1android-2.3.4_r1
這一步大概有一分多鐘就完成了。
如果需要下載其他分支將android-2.3.4_r1 改成其他分支名稱就可以了。分支名稱請(qǐng)?jiān)趆ttps://android.googlesource.com/platform/manifest/+refs 里面查看branch
比如下載android-4.4_r1.2
repo init -u https://android.googlesource.com/platform/manifest -b android-4.4_r1.2
9.執(zhí)行repo sync 進(jìn)行同步
出現(xiàn)問題:
builder56@builder56-desktop:~/google/android_source/.repo$ repo sync
... A new repo command ( 1.18) is available.
... You should upgrade soon:
cp /home/builder56/google/android_source/.repo/repo/repo /home/builder56/bin/repo
解決方法:執(zhí)行命令 cp /home/builder56/google/android_source/.repo/repo/repo /home/builder56/bin/repo
9.1問題Network is unreachable while accessing https://android.googlesource.com/platform/development/info/refs
解決方法:sudo gedit /etc/hosts host 文件
添加內(nèi)容:
74.125.237.1 dl-ssl.google.com
74.125.71.82 www.googlesource.com
74.125.31.82 android.googlesource.com
203.208.46.172 cache.pack.google.com
59.24.3.173cache.pack.google.com
9.2 出現(xiàn)下載過程中,沒有斷網(wǎng)確一直不動(dòng)的情況
創(chuàng)建腳本download.sh
#!/bin/bash echo "======start repo sync======" repo sync while [ $? == 1 ]; do echo "======sync failed, re-sync again======" sleep 3 repo sync done
chomd a+x download.sh讓其可以運(yùn)行,然后終端輸入./download.sh就可以開始下載了,用這一步代替官方文檔里的repo sync。當(dāng)連接不上終端時(shí)休息3毫秒然后再自動(dòng)repo sync,這樣就不用一直等著不用下班了。
如果有時(shí)間一直等這看,那句直接ctrl+c 取消下載,再輸入repo sync.
下載完成,上圖:
10.編譯
由于我工作的電腦jdk 等環(huán)境之前已經(jīng)按照了,所以不需要其他操作了。
10.1:具體可以去看google 的網(wǎng)站。我這里只是寫自己的過程。
$ source build/envsetup.sh
or
$ . build/envsetup.sh
然后,執(zhí)行:make -j8 (我的 cpu 是8核的)
聯(lián)系客服