先前偶爾會在虛擬機器裡編譯 Android,這兩天也試在稍早安裝的 Debian (32bit) 上嘗試編譯 Android 4.0 (ICS),首先遇上的問題是記憶體的部份。首先我將虛擬機器裡的記憶體設定成 1GB,所以編譯時遇上了這個問題:
target Dex: core Error occurred during initialization of VM Could not reserve enough space for object heap Could not create the Java virtual machine. make: *** [out/target/common/obj/JAVA_LIBRARIES/core_intermediates/noproguard.classes-with-local.dex] Error 1
這個容易處理,修改 core/definitions.mk 這個檔案是可以解決的,修改方式如下:
diff --git a/core/definitions.mk b/core/definitions.mk index b678158..b83b299 100644 --- a/core/definitions.mk +++ b/core/definitions.mk @@ -1525,7 +1525,7 @@ define transform-classes.jar-to-dex @echo "target Dex: $(PRIVATE_MODULE)" @mkdir -p $(dir $@) $(hide) $(DX) \ - $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M) \ + $(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1024M) \ --dex --output=$@ \ $(incremental_dex) \ $(if $(NO_OPTIMIZE_DX), \
但,最後卻在編譯 qemu 時又出現錯誤,爬了文之後,在 "Build android ICS on ubuntu 32 bits" 這串討論文章裡看到以下這麼一段:
Indeed, with the emulator moving to 64-bit, building on 32-bit hosts is not an option any more (not even unsupported).
噗~~~既然我主要的環境都是 64 位元,而且在 32 位元的 Debian GNU/Linux 上也只是順手試試,那麼就先暫時到這裡吧! XD