Ubuntu 12.04 server (64-bit) Android compilation encounters the Java Virtual Machine heap memory insufficiency problem unexpected top-level error: Java. lang. outofmemoryerror: GC overhead limit exceeded at com. android. DX. dex. code. outputfinisher. findexpandedopcodeforinsn (outputfinisher. java: 525) at com. android. DX. dex. code. outputfinisher. calculatereservedcount (outputfinisher. java: 466) at com. android. DX. dex. code. outputfinisher. reserveregisters (outputfinisher. java: 402) at com. android. DX. dex. code. outputfinisher. finishprocessingandgetlist (outputfinisher. java: 358) at com. android. DX. dex. code. dalvcode. finishprocessingifnecessary (dalvcode. java: 108) at com. android. DX. dex. code. dalvcode. getinsns (dalvcode. java: 185) at com. android. DX. dex. file. codeitem. place0 (codeitem. java: 223) at com. android. DX. dex. file. offsetteditem. place (offsetteditem. java: 242) at com. android. DX. dex. file. mixeditemsection. placeitems (mixeditemsection. java: 312) at com. android. DX. dex. file. dexfile. todex0 (dexfile. java: 543) at com. android. DX. dex. file. dexfile. todex (dexfile. java: 216) at com. android. DX. command. dexer. main. writedex (main. java: 574) at com. android. DX. command. dexer. main. run (main. java: 218) at com. android. DX. command. dexer. main. main (main. java: 174) at com. android. DX. command. main. main (main. java: 95) Make: *** [out/target/common/obj/java_libraries/framework_intermediates/noproguard. A classes-with-local.dex] Error 3
Solution:
Method 1:
Use Java commands to specify the size of the Java Virtual Machine heap to compile the required items first. It may take several minutes.
Java-xms3550m-xmx3550m-Jar/home/test/4.0/out/host/linux-x86/framework/dx. jar -- Dex -- output = out/target/common/obj/java_libraries/framework_intermediates/noproguard. classes-with-local.dex -- Core-library out/target/common/obj/java_libraries/framework_intermediates/noproguard. classes. jar
After running this command. Make again. Because the package has been made, it will not be compiled again when you make it again.
This method can only be executed after the make command fails, and then the make command is executed later.
Method 2:
Modify the definitions. mk file. This file is located in the build/CORE/directory.
Variable:-jxms16m-jxmx1024m value in the transform-classes.jar-to-dex
Variable definition in the Code:
Define transform-classes.jar-to-dex
@ Echo "target DEX: $ (private_module )"
@ Mkdir-p $ (DIR $ @)
$ (Hide) $ (dx )\
$ (If $ (findstring windows, $ (host_ OS),-jxms16m-jxmx1024m )\
-- Dex -- output =$ @\
$ (If $ (no_optimize_dx ),\
-- No-optimize )\
$ (If $ (generate_dex_debug ),\
-- Debug -- verbose \
-- Dump-To = $ (@:. DEX =. lst )\
-- Dump-width = 1000 )\
$ (Private_dx_flags )\
$ <
Endef
Change-jxms16m-jxmx1024m to an appropriate value.
My machine is 32 GB in memory, and I changed-jxms16m-jxmx1024m to-jxms1024m-jxmx2048m
The size of the specific value depends on the memory of the specific machine. If the value of memory is too small, the problem may occur.