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


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

前沿

    最近在研究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

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

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM