Question

When I include the espresso snapshot jar in my project, my gradle compilations hang and then kick out with the following message:

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

From my research it sounds like this is a dependency issue. How would you recommend I go about resolving this?

I tried bumping the heap space (-Xmx2048), but the build ran for a long period of time (several minutes) all the while my computer got hotter and hotter but didn't finish. It never takes more than a minute to compile without this jar.

Was it helpful?

Solution 2

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

OTHER TIPS

I think there's a separate way to raise the heap limit of the dexing operation. Add this to your android closure in your build.gradle file:

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top