2021-05-12 14:32:11
32位元Ubuntu編譯Android 4.0.4問題
問題一:在32位元Ubuntu 12.04上編譯Android4.0.4原始碼時,出現了關於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
問題二:編譯時出現如下提示:
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檔案發現如下內容:
#TODO: use a smaller -Xmx value for most libraries;
# only core.jar and framework.jar need a heap this big.
# Avoid the memory arguments on Windows, dx fails to load for some reason with them.
define transform-classes.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"
@mkdir -p $(dir $@)
$(hide) $(DX)
$(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx2048M)
--dex --output=$@
$(incremental_dex)
$(if $(NO_OPTIMIZE_DX),
--no-optimize)
$(if $(GENERATE_DEX_DEBUG),
--debug --verbose
--dump-to=$(@:.dex=.lst)
--dump-width=1000)
$(PRIVATE_DX_FLAGS)
$<
endef
由於我的電腦只有2GB的內容,那麼上面的2048M肯定滿足不了,因為linux分配時還需分配給核心記憶體,故將該引數調小為1024M。
繼續編譯還會出現一些關於emulator的錯誤,而查閱了google官方資料,說是要在64bit系統上編譯,換成64位元的後,沒出現什麼錯誤,編譯一切正常。
相關文章