2

When I run my gradle build from the command line, it fails during the lintVital[buildType] task. When I run the same build within Android Studio, it works without issue.

My command line execution:

./gradlew assembleRelease

The console output I receive after the lintVital task starts:

:app:lintVitalRelease Failed converting ECJ parse tree to Lombok for file /Users/dalvikdroid/AndroidstudioProjects/myproject/app/src/main/java/com/example/android/common/Constants.java java.lang.OutOfMemoryError: Java heap space at java.util.EnumMap.(EnumMap.java:113) at com.google.common.collect.Maps.newEnumMap(Maps.java:335) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:227) at lombok.ast.ecj.EcjTreeConverter.createVariableDefinition(EcjTreeConverter.java:351) at lombok.ast.ecj.EcjTreeConverter.toVariableDefinition(EcjTreeConverter.java:305) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:273) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.createNormalTypeBody(EcjTreeConverter.java:562) at lombok.ast.ecj.EcjTreeConverter$2.visitTypeDeclaration(EcjTreeConverter.java:494) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:48) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at lombok.ast.ecj.EcjTreeConverter.toTree(EcjTreeConverter.java:236) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:282) at lombok.ast.ecj.EcjTreeConverter.fillList(EcjTreeConverter.java:252) at lombok.ast.ecj.EcjTreeConverter.access$100(EcjTreeConverter.java:141) at lombok.ast.ecj.EcjTreeConverter$2.visitCompilationUnitDeclaration(EcjTreeConverter.java:440) at lombok.ast.ecj.EcjTreeVisitor.visitEcjNode(EcjTreeVisitor.java:264) at lombok.ast.ecj.EcjTreeConverter.visit(EcjTreeConverter.java:295) at com.android.tools.lint.EcjParser.parseJava(EcjParser.java:360) at com.android.tools.lint.client.api.JavaVisitor.visitFile(JavaVisitor.java:194) at com.android.tools.lint.client.api.LintDriver.checkJava(LintDriver.java:1660) at com.android.tools.lint.client.api.LintDriver.runFileDetectors(LintDriver.java:1024) at com.android.tools.lint.client.api.LintDriver.checkProject(LintDriver.java:880) at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:431) at com.android.tools.lint.client.api.LintDriver.analyze(LintDriver.java:374) at com.android.tools.lint.LintCliClient.run(LintCliClient.java:116) at com.android.build.gradle.internal.LintGradleClient.run(LintGradleClient.java:102) at com.android.build.gradle.internal.LintGradleClient$run.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

After this output, every consecutive file it hits fails the same way until I finally receive:

:app:lintVitalRelease FAILED

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:lintVitalRelease'.

    Java heap space

  • Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

After reading about this online I tried increasing my heap size (as mentioned here), but so far this has only prolonged the inevitable failure message.

The exact file that first causes the OutOfMemoryError changes with each run, so I'm having a hard time pinpointing what could be causing this.

Janusz
  • 187,060
  • 113
  • 301
  • 369
DalvikDroid
  • 523
  • 6
  • 14

3 Answers3

4

Finally figured this out. A few posts online suggested setting DEFAULT_JVM_OPTS="-Xmx512m" in the graddle wrapper (graddlew), but that didn't do it for me.

Instead of setting DEFAULT_JVM_OPTS, set

GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"

in your graddle wrapper to increase the heap size.

In windows you should edit gradlew.bat file and add this line: set GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"

DalvikDroid
  • 523
  • 6
  • 14
1

You can try this.

lintOptions {
    checkReleaseBuilds false
}

see gradle build fails on lint task

Community
  • 1
  • 1
  • This answer still helped me, the essential lintOption is here. Why would we lint the release builds in the first place? They do not have different code than debug.. – Zasz Mar 21 '16 at 17:32
0

In gradlew script file, add the following:

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="-Xmx512m"
John Difool
  • 5,572
  • 5
  • 45
  • 80