编译4.0源码时会遇到java虚拟机堆内存不够的问题

报的错误是类似于这种的:


UNEXPECTED TOP-LEVEL ERROR:
java.lang.AssertionError
        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.classes-with-local.dex] error 3



解决方法:

用java命令指定java虚拟机堆的大小来把需要编译的东西先编译出来,可能需要几分钟。


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


运行完这个后。再重新make就好了,因为这个包已经被make出来了,所以重新make的时候不会再去编译它。

你可能感兴趣的:(java,虚拟机)