2

当我在项目中包含 espresso 快照 jar 时,我的 gradle 编译挂起,然后退出并显示以下消息:

UNEXPECTED TOP-LEVEL ERROR:
java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.util.Arrays.copyOf(Arrays.java:2219)
    at java.util.ArrayList.toArray(ArrayList.java:358)
    at java.util.ArrayList.<init>(ArrayList.java:164)
    at com.android.dx.ssa.SsaMethod.getUseListCopy(SsaMethod.java:660)
    at com.android.dx.ssa.ConstCollector.updateConstUses(ConstCollector.java:333)
    at com.android.dx.ssa.ConstCollector.run(ConstCollector.java:147)
    at com.android.dx.ssa.ConstCollector.process(ConstCollector.java:75)
    at com.android.dx.ssa.Optimizer.runSsaFormSteps(Optimizer.java:181)
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:99)
    at com.android.dx.ssa.Optimizer.optimize(Optimizer.java:72)
    at com.android.dx.dex.cf.CfTranslator.processMethods(CfTranslator.java:303)
    at com.android.dx.dex.cf.CfTranslator.translate0(CfTranslator.java:139)
    at com.android.dx.dex.cf.CfTranslator.translate(CfTranslator.java:94)
    at com.android.dx.command.dexer.Main.processClass(Main.java:682)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at com.android.dx.command.dexer.Main.main(Main.java:199)
    at com.android.dx.command.Main.main(Main.java:103)
:Project:dexFlavorEnterpriseDebug FAILED

根据我的研究,这听起来像是一个依赖问题。你会建议我如何解决这个问题?

我尝试碰撞堆空间(-Xmx2048),但构建运行了很长一段时间(几分钟),而我的计算机越来越热但没有完成。如果没有这个 jar,编译永远不会超过一分钟。

4

2 回答 2

6

我认为有一种单独的方法可以提高 dexing 操作的堆限制。将此添加到您的 build.gradle 文件中的 android 闭包中:

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
于 2014-12-12T13:35:28.290 回答
0

This seemed to be some sort of Maven library dependency issue. I fixed the issue by removing certain libraries... Flurry in this instance.

Maven dependencies are usable but don't merge well with Android + Gradle when there are conflicts. Unfortunately don't have a lot of other information to share. :(

Edit:

You may want to check out Jake Wharton's double-espresso for better Gradle compatibility. https://github.com/JakeWharton/double-espresso

于 2013-12-25T22:03:10.480 回答