gpt4 book ai didi

Android Gradle lintVital OutofMemoryError 崩溃构建

转载 作者:搜寻专家 更新时间:2023-11-01 07:57:45 25 4
gpt4 key购买 nike

当我从命令行运行我的 gradle build 时,它在 lintVital[buildType] 任务期间失败。当我在 Android Studio 中运行相同的构建时,它可以正常工作。

我的命令行执行:

./gradlew assembleRelease

我在 lintVital 任务启动后收到的控制台输出:

: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)

在此输出之后,它命中的每个连续文件都以相同的方式失败,直到我最终收到:

:app:lintVitalRelease FAILED

FAILURE: Build failed with an exception.

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

    Java heap space

  • 尝试:使用 --stacktrace 选项运行以获取堆栈跟踪。使用 --info 或 --debug 选项运行以获得更多日志输出。

构建失败

在线阅读此内容后,我尝试增加堆大小(如 here 所述),但到目前为止,这只会延长不可避免的失败消息。

首先导致 OutOfMemoryError 的确切文件在每次运行时都会发生变化,因此我很难确定可能导致此问题的原因。

最佳答案

终于明白了。一些在线帖子建议在 gradle 包装器 (gradlew) 中设置 DEFAULT_JVM_OPTS="-Xmx512m",但这并没有为我做。

不是设置 DEFAULT_JVM_OPTS,而是设置

GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"

在你的 gradle 包装器中增加堆大小。

在 Windows 中,您应该编辑 gradlew.bat 文件并添加此行:set GRADLE_OPTS="$GRADLE_OPTS -Xmx512m"

关于Android Gradle lintVital OutofMemoryError 崩溃构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25555538/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com