Ubuntu9.10下編譯Android源碼

在 Ubuntu8.04下,應該一切很順利,但是我裝的是9.10版本,所以會有些問題。

先裝jdk1.5,網上說1.6的有點小問題,所以我沒裝1.6,選擇了1.5. 然後一邊裝必須的一些程序,apt-get install **** 很多亂七八糟的,網上能搜到,然後一邊下載android源碼。

 

源碼的下載需要git,curl和repo,git和curl可以直接用apt-get install git-core curl就可以了

然後下載repo

curl http://android.git.kernel.org/repo >~/bin/repo

 

添加可執行權限

sudo chmod +x repo

 

初始化repo

repo init -u git://android.git.kernel.org/platform/manifest.git

 

如果只需要某一個版本,比如我只要cupcake

repo init -u git://android.git.kernel.org/platform/manifest.git -b cupcake

 

然後建個目錄,

mkdir android

進入

cd android

下載

repo sync

 

然後就等吧,大概兩個G左右的內容,在獲取39%的時候和95%的時候是最慢的,因爲39%的有一百多M,95%的有差不多400M。

下載完之後,先不要make,因爲還有幾個問題:

1.如果直接make,會出現frameworks/policies/base/PolicyConfig.mk:22: *** No module defined for the given PRODUCT_POLICY (android.policy_phone).  Stop.錯誤。

解決辦法:

在build/tools/findleaves.sh中的第89行,
這一句find "
${@:0:$nargs
}" $findargs -type f -name "$filename" -print |

改爲find "${@:1:$nargs-1}" $findargs -type f -name "$filename" -print |

2.frameworks/base/tools/aidl/AST.cpp:10: error: 'fprintf' was not declared in this scope的錯誤

解決辦法:

下載gcc-4.3和g++-4.3

apt-get install gcc-4.3 g++-4.3

大約十多兆,然後

進入/usr/bin

cd /usr/bin

建個軟連接

ln -s gcc-4.3 gcc

ln -s g++-4.3 g++

然後進入android目錄下,執行make,就可以了。

我在虛擬機裏面make的,分了1G內存給他,處理器50%,一共花了兩個小時才編譯完成。編譯完成後,在android目錄下的out文件夾中,就是結果,也有兩個G左右。

在out/target/product/generic目錄下,有三個img文件,system.img,ramdisk.img,userdata.img,這三個就是需要的android系統鏡像文件,放到模擬器中運行就行了。

運行出來之後,進入設置裏面,可以看到自己編譯的標識呢,嘿嘿,很有成就感的。

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