出错的log信息如下
UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
at com.android.dx.ssa.SsaBasicBlock.<init>(SsaBasicBlock.java:125)
at com.android.dx.ssa.SsaMethod.makeNewGotoBlock(SsaMethod.java:240)
at com.android.dx.ssa.SsaBasicBlock.insertNewSuccessor(SsaBasicBlock.java:454)
at com.android.dx.ssa.SsaConverter.edgeSplitMoveExceptionsAndResults(SsaConverter.java:210)
at com.android.dx.ssa.SsaConverter.edgeSplit(SsaConverter.java:136)
at com.android.dx.ssa.SsaConverter.convertToSsaMethod(SsaConverter.java:48)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:99)
at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:73)
at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:273)
at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:134)
at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:87)
at com.android.dx.command.dexer.Main.processClass(Main.java:483)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
at com.android.dx.command.dexer.Main.access$400(Main.java:67)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
at com.android.dx.command.dexer.Main.processOne(Main.java:418)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
at com.android.dx.command.dexer.Main.run(Main.java:206)
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
解决方法:
更改编译配置文件build/core/definitions.mk中的缓存参数:
define transform-classes.jar-to-dex
@echo "target Dex: $(PRIVATE_MODULE)"
@mkdir -p $(dir $@)
$(hide) $(DX) \
$(if $(findstring windows,$(HOST_OS)),,-JXms16M -JXmx1536M) \
--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
将红色标注部分的参数值更改为较大的值:-JXms1024M -JXmx1536M (我的机器是8G内存),然后再次make,错误应该就不会再出现了。
不过参数的数值请根据自己的机器适当的改大,数值太大编译时会很卡。
Good luck to you~