Ubuntu9.10下編譯Android源碼

 

先裝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,就可以了。

3.

 

------------------------------------------------------------------------------------------------
error type : undeclared or Error 1.
------------------------------------------------------------------------------------------------
host C: emulator <= external/qemu/console.c
host C: emulator <= external/qemu/loader.c
host C: emulator <= external/qemu/sockets.c
external/qemu/sockets.c: In function ‘sock_address_init_resolve’:
external/qemu/sockets.c:637: error: ‘EAI_NODATA’ undeclared (first use in this function)
external/qemu/sockets.c:637: error: (Each undeclared identifier is reported only once
external/qemu/sockets.c:637: error: for each function it appears in.)
make: *** [out/host/linux-x86/obj/EXECUTABLES/emulator_intermediates/sockets.o] Error 1

 

=========================================================
 Solution:
=========================================================
The 1st way to fix:
Apparently you have to modify the makefile to fix it. 
/external/qemu/Makefile.android
# this is needed to build the emulator on 64-bit Linux systems
 ifeq ($(HOST_OS)-$(HOST_ARCH),linux-x86)
-  MY_CFLAGS += -Wa,--32
+  MY_CFLAGS += -Wa,--32 -D_GNU_SOURCE
 endif
 ifeq ($(HOST_OS),freebsd) 

The 2st way to fix:
commenting out the EAI_NODATA line
found in sockets.c file.
             err = EHOSTDOWN;
             break;

-        case EAI_NODATA:
+        /* case EAI_NODATA: */
         case EAI_NONAME:
             err = ENOENT;
             break; 

=========================================================

 

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

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

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

*********************************

$ sudo apt-get install lib32readline5-dev

lib32readline5-dev不存在,實際上只要libreadline5-dev 即可

************************************

 


 

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