Android编译中遇到的问题

1、在编译过程中出现Java虚拟机内存不够的问题

编译的错误如下所示:

Aidl Preprocess: out/target/common/obj/framework.aidl
make: *** 没有规则可以创建“out/target/common/obj/PACKAGING/checkapi-current-timestamp”需要的目标“frameworks/base/api/current.txt”。 停止。
make: *** 正在等待未完成的任务....
Copy: apicheck (out/host/linux-x86/obj/EXECUTABLES/apicheck_intermediates/apicheck)

UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: Java heap space
        at com.android.dx.util.Bits.makeBitSet(Bits.java:38)
        at com.android.dx.util.BitIntSet.(BitIntSet.java:35)
        at com.android.dx.ssa.InterferenceRegisterMapper.addInterfence(InterferenceRegisterMapper.java:124)
        at com.android.dx.ssa.InterferenceRegisterMapper.addMapping(InterferenceRegisterMapper.java:68)
        at com.android.dx.ssa.back.FirstFitLocalCombiningAllocator.addMapping(FirstFitLocalCombiningAllocator.java:706)
        at com.android.dx.ssa.back.FirstFitLocalCombiningAllocator.handleLocalAssociatedParams(FirstFitLocalCombiningAllocator.java:194)
        at com.android.dx.ssa.back.FirstFitLocalCombiningAllocator.allocateRegisters(FirstFitLocalCombiningAllocator.java:130)
        at com.android.dx.ssa.back.SsaToRop.convert(SsaToRop.java:105)
        at com.android.dx.ssa.back.SsaToRop.convertToRopMethod(SsaToRop.java:70)
        at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:102)
        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:91)
make: *** [out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/noproguard.classes-with-local.dex] 错误 3

解决方法好像有两种:

A.修改build/core/definitions.mk文件中-JXms和-JXmx对应的值,其中,前者表示内存的最小值,后者表示内存的最大值;

B.通过执行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














你可能感兴趣的:(Andorid)