Mac上編譯並運行Android5.0源碼

來源:互聯網
上載者:User

標籤:

下載、配置環境、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源碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.