標籤:
下載、配置環境、build和運行參考的都是Android Source提供的文檔,包括:Initializing a Build Environment,Downloading the Source和Building the System。
我是在OSX 10.10.3上編譯的AOSP,記錄一下中途碰到的各種問題。
下載
AOSP需要FQ,而且經常會斷,還好是斷點續傳,堅持個兩三天怎麼也能下下來。
case sensitive system
我在Mac上對file system只會用Disk Utility進行操作。
make error 1
fatal error: linux/netfilter/xt_DSCP.h: No such file or directory
在目錄external/iptables/extensions/../include/linux/netfilter中建立檔案xt_DSCP.h。
/** based on ipt_FTOS.c (C) 2000 by Matthew G. Marsh <[email protected]>* This software is distributed under GNU GPL v2, 1991** See RFC2474 for a description of the DSCP field within the IP Header.** xt_DSCP.h,v 1.7 2002/03/14 12:03:13 laforge Exp*/#ifndef _XT_DSCP_TARGET_H#define _XT_DSCP_TARGET_H#include <linux/netfilter/xt_dscp.h>#include <linux/types.h>/* target info */struct xt_DSCP_info { __u8 dscp;};struct xt_tos_target_info { __u8 tos_value; __u8 tos_mask;};#endif /* _XT_DSCP_TARGET_H */
make error 2
大概錯誤提示是jni_generator.py找不到substring方法,Google一番發現應該是JDK的版本有問題,使用Jenv將Mac的JDK版本設定為1.7可以解決。
make error 3
No space left on device
使用Disk Utility增加dmg的大小。
emulator 1
方便使用,需要在.bash_profile中增加:
export PATH=/Volumes/[dmg title]/android/out/host/darwin_x86/bin
需要注意的是OSX 10.10.3版本中bin目錄下沒有產生emulator,可以將PATH該為/Volumes/[dmg title]/android/prebuilts/android-emulator/darwin-x86x64,也可以將emulator從該目錄拷到/Volumes/[dmg title]/android/out/host/darwinx86/bin下。
emulator 2
export ANDROID_PRODUCT_OUT=/Volumes/[dmg title]/android/out/target/product/generic
為什麼export這個,請參考羅昇陽的《Android系統原始碼情景分析》。
emulator 3
加完這兩個export後會報如下錯誤:
emulator: ERROR: You did not specify a virtual device name, and the system directory could not be found.
If you are an Android SDK user, please use ‘@<name>‘ or ‘-avd <name>‘ to start a given virtual device (see -help-avd for details).
Otherwise, follow the instructions in -help-disk-images to start the emulator
增加:
export ANDROID_BUILD_TOP=/Volumes/[Volumes]/android
emulator 4
最後解決如下錯誤:
emulator: WARNING: system partition size adjusted to match image file (550 MB > 200 MB)emulator: WARNING: data partition size adjusted to match image file (550 MB > 200 MB)
運行emulator時增加參數:
emulator -partition-size 1024
Finally
最終在Mac上編譯成功AOSP,並成功運行emulator,可以做進一步源碼研究。
Reference
- fatal error: linux/netfilter/xt_DSCP.h: No such file or directory
- jelly bean(adnroid4.1.1)下emulator不能直接啟動並執行問題
- ubuntu編譯安卓5.0源碼小記
Mac上編譯並運行Android5.0源碼