標籤:android http io os 使用 ar strong for 檔案
android源碼下載及安裝:
1.初始化安裝環境:
A。建立大小寫敏感硬碟鏡像:
步驟如下:
Disk Utility –> New Image,隨便取個名字,這裡用AndroidDisk,30GB足夠了,然後注意選成Mac OS Extended (Case-sensitive, Journaled), –> Create
記住儲存路勁為
~/AndroidDisk.dmg
B。掛載鏡像:
使用命令:
hdiutil attach ~/AndroidDisk.dmg -mountpoint /Volumes/android
Google的官網上推薦把這行加到~/.bash_profile裡,這樣以後每次用mountAndroid命令就行了。
# mount the android file image function mountAndroid { hdiutil attach ~/AndroidDisk.dmg -mountpoint /Volumes/android; }
(記住路徑和檔案名稱的正確書寫)
C。安裝Xcode和MacPorts:
Xcode不用多說了,MacPorts從http://www.macports.org/install.php下載:
安裝MacPorts之前需要確認環境變數PATH中,/opt/local/bin出現在/usr/bin之前,可以運行一下這行來確認:
$ echo $PATH
否則,就運行一下:
$ export PATH=/opt/local/bin:$PATH
並把上面那行加在~/.bash_profile裡。
D。從MacPorts安裝make, git, and GPG packages:
$ POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg
如果你是Mac OS X 10.4版本的話,還要安裝個bison
$ POSIXLY_CORRECT=1 sudo port install bison
E.下面要把gmake 3.82還原到3.81,否則之後編譯源碼會出錯:(3.82有Bug,用不了):
$ sudo vim /opt/local/etc/macports/sources.conf
然後在rsync那行的上面一行加上
file:///Users/Shared/dport
之後按這個步驟來就行了:
$ mkdir /Users/Shared/dports
$ cd /Users/Shared/dports/
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
$ portindex /Users/Shared/dports
安裝3.81版的:
$ sudo port install gmake @3.81
檢查一下gmake版本,看到版本號碼是3.81就對了:
$ gmake --version
於是最後下載Android源碼前的最後一步就是,修改檔案標識符限制:
由於Mac OS 預設將同時開啟的檔案標識符數量限制得太小,並行編譯處理時可能會超出這個限制。所以在 ~/.bash_profile 裡加上這麼一段:
# set the number of open files to be 1024
ulimit -S -n 1024
2.下載源碼:
安裝Git Repo:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
初始化Git Repo進入開始時掛載的鏡像硬碟,建立一個工作目錄:
$cd /Volumes/AndroidDisk
$makedir WorkingSpace/
$cd Working Space/
$ repo init -u https://android.googlesource.com/platform/manifest
在執行這個檔案的時候,可能會出現錯誤,
問題1
但是在repo 初始化過程中卻遇到一個問題
/root/bin/repo line 1: syntax error near unexpected token `newline‘
以前也下過源碼,卻沒有碰到過這種問題
經過測試,重新下載
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ repo init -u https://android.googlesource.com/platform/manifest
$ repo sync
注意這裡是https ,不是http
開始寫成http的時候就產生了上面的問題
$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.0.1_r1
同步檔案:
$ repo sync
(開始下載repo裡的檔案——源碼。於是似乎睡一覺的時間又到了。。)
再import一個GPG public key,
$ gpg --import
以下是官網給出的key,輸入完按Ctrl+D結束
Mac 下 下載Android源碼步驟