【Android】Android 4.2源碼下載(ubuntu 12.10)

原文鏈接http://www.cnblogs.com/skyseraph/archive/2013/02/26/2933981.html

前沿

最近在研究NFC,這個不同在不同版本中API的使用都不同,想看下其源碼實現,於是乎得重新下載下android源碼了~~~

完整步驟

Installing some soft

1 Install curl: sudo apt-get install curl

2 Install git-core: sudo apt-get install git-core

Installing Repo

1 在用戶目錄下創建一個~/bin目錄,並添加到環境變量中(要將git軟件下載安裝在此目錄,在別的目錄運行可能會找不到此軟件,所以要添加到環境變量中)

$ mkdir ~/bin

$ PATH=~/bin:$PATH

2 下載repo腳本並修改權限爲可執行

$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

$ chmod a+x ~/bin/repo

Initializing a Repo client

1 創建一個保存android源碼的目錄,修改爲最大權限,並進入到該目錄下

$ mkdir /opt/android4.2

$ sudo chmod –R 777 /opt/android4.2

$ cd /opt/android4.2

2 初始化repo,並選擇要下載的分支(版本)

$ repo init -u https://android.googlesource.com/platform/manifest

$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2_r1

備註1:在這過程中需要輸入你的姓名、郵箱等信息

備註2:查詢android版本信息,參考 https://android.googlesource.com/platform/manifest/+refs

Getting the files

$ repo sync

問題

代碼下載過程中,經常提示以下錯誤:

error: Failed connect to android.googlesource.com:443;Connection refused while accessinghttps://android.googlesource.com/a/platform/frameworks/base/info/refs

fatal: HTTP request failed

error: Cannot fetch platform/tools/motodev

error: Cannot fetch platform/frameworks/base

error: Cannot fetch platform/prebuilts/sdk

error: Exited sync due to fetch errors

解決方法:編輯/etc/hosts文件

$ vim /etc/hosts

增加下面內容,保存(提前保存好):

74.125.31.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

然後重新輸入

$ repo sync

Android4.2還算比較大,打包後大概9.5G左右,不打包14G左右

Ref:

1 Downloading the Source Tree: http://source.android.com/source/downloading.html

2 android4.2源碼下載過程: http://blog.csdn.net/lengxibo/article/details/8299888#reply

3 http://zhu.im/Android/ 非常好的一個鏈接,裏面1.6到4.2各個版本都有,如果懶得自己下載就直接在此下載

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章