Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux教程

32 位 Ubuntu 編譯 Android 4.0.4 遇到的問題

本文記錄在 32 位 Ubuntu 12.04 上編譯 Android 4.0.4 原始碼時遭遇的兩個問題與解法。

問題一:emulator 相關錯誤

編譯時出現關於 emulator 的錯誤,關鍵在其 Makefile 裡的 -m64 參數,將其改為 -m32 即可。錯誤提示如下:

ERROR: prebuilts/tools/gcc-sdk/../../gcc/linux-x86/host/x86_64-linux-glibc2.7-4.6/bin/x86_64-linux-gcc only run on 64-bit linux

make: *** [out/host/linux-x86/obj/STATIC_LIBRARIES/emulator64-target-arm_intermediates/tcg/tcg.o] Error 1

需修改的檔案為 external/qemu/Makefile.target 與 external/qemu/Makefile.common。

問題二:Java 虛擬機記憶體不足

編譯時出現:

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

查看 build/core/definitions.mk 會發現 transform-classes.jar-to-dex 中設定了 -JXmx2048M。由於我的電腦只有 2GB 記憶體,加上 Linux 還要分配給核心,因此把該參數調小為 1024M。

繼續編譯仍會出現一些 emulator 相關錯誤。查閱 Google 官方資料後得知需在 64 位系統上編譯,換成 64 位後便一切正常。

Copyright © Linux教程網 All Rights Reserved