Lint在组装发布目标时发现了致命错误


82

383/5000我有一个应用程序,当我将其更改为发布模式以将其上传到Play商店时,会出现编译错误

我已经尝试过分析检查代码,但没有任何错误。

我还尝试了在构建build gradle中的编译建议,它没有给出错误,但是当我尝试安装apk时,它给了我一个错误:“ APK安装失败。错误:无法停止错误字符串”

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:lintVitalRelease'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.gradle.api.GradleException: Lint found fatal errors while assembling a release target.

To proceed, either fix the issues identified by lint, or modify your build script as follows:
...
android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}
...
    at com.android.tools.lint.gradle.LintGradleExecution.abort(LintGradleExecution.java:199)
    at com.android.tools.lint.gradle.LintGradleExecution.runLint(LintGradleExecution.java:263)
    at com.android.tools.lint.gradle.LintGradleExecution.lintSingleVariant(LintGradleExecution.java:359)
    at com.android.tools.lint.gradle.LintGradleExecution.analyze(LintGradleExecution.java:93)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.android.tools.lint.gradle.api.ReflectiveLintRunner.runLint(ReflectiveLintRunner.kt:38)
    at com.android.build.gradle.tasks.LintBaseTask.runLint(LintBaseTask.java:87)
    at com.android.build.gradle.tasks.LintPerVariantTask.lint(LintPerVariantTask.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:46)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:780)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:747)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    ... 32 more

Answers:


154
  1. 您可以使用“分析”>“检查代码”菜单来手动运行检查。结果将显示在“检验结果”窗口中。这样,您可以查看和解决实际问题。

  2. 您仍然可以从app \ build \ reports \ lint-results-release-fatal.html文件中查看它们,而无需使用上述手动检查菜单。

  3. 尽管不建议您按照Android Studio的建议通过在build.gradle中添加以下代码来抑制掉毛警告。但是请记住,这不会解决任何实际问题。

android {
    lintOptions {
        checkReleaseBuilds false
        // Or, if you prefer, you can continue to check for errors in release builds,
        // but continue the build even when errors are found:
        abortOnError false
    }
}

27
你是救生员。分析->检查代码是最好的工具。
J.杰斐逊'18年

13
同意。令人惊讶的是,即使最新的Android Studio在由于lint失败而导致Build失败后也没有指向此链接,它只是显示一个代码片段来禁用错误.... !!!?
BjornW

1
这个答案的最后一部分非常有价值。我将编辑答案,以首先放置“分析->检查代码”,以使人们不会错过它。关于抑制警告的部分已经在Android Studio中显示,并且您应该说是不得已的方法。
LarsH

1
@BjornW确保他们将来会修复它。只要给他们一些时间,您就可以看到他们在每个发行版中所做的工作,修复和改进的冰山一角。他们每年必须赶上所有Google的新API,并不断改进IDE。实际上,Android Studio是目前最好的IDE之一。
Kirill Karmazin

62

您可以在应用程序路径中找到详细信息

 /YOUR_APPLICATION/app/build/reports/ 

在此处输入图片说明

在此文件夹中,有一个描述该错误的HTML文档。

有关更多信息,您可以访问我找到解决方案的页面。

https://dominoc925.blogspot.com/2018/08/how-to-find-cause-of-lint-error-while.html


2
这是正确的解决方案。分析>检查代码生成的条目太多,无法找到实际的罪魁祸首。
Rammohan Raja'2

1
感谢您的解决方案...花了我10个小时的时间,一个人纠正了棉绒警告,最后使用了您的解决方案。我有这个问题的确切原因。非常感谢
阿米特森

49

在这里,我写了一篇文章,讨论了解决Lint发现致命错误的所有可能解决方案

通常,您可以通过以下方式解决它:

Android Studio在以下链接中显示了htmlxml文件中的所有构建错误。只需在浏览器中打开该文件,检查错误并修复即可。

/YOUR_APPLICATION/app/build/reports/lint-results-release-fatal.html

在此处输入图片说明

样本误差

在此处输入图片说明


1
大!!我认为这是解决问题的完美方法
拉胡尔·米什拉

这个答案对我真的很有帮助,谢谢@Asad
Abhra

5

确保在应用程序的所有string.xml文件中定义了所有翻译。


1

对我来说,我检查了/ APPLICATION / app / build / reports中xml和html文件中的错误,然后我修复了所有可以解决的问题,其余的我通过在build.gradle中添加以下代码来抑制了它们:

android {
    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

这可以防止android studio因剩余错误而中止构建




-1

File > Invalid Caches/Restart为我解决了这个问题。我刚刚开始使用Android,但是我想尝试一下上面提到的内容之前,先尝试一下,然后开始工作。


-1

有两种解决方法-

1->转到分析>检查代码,让它检查代码,然后解决问题。

2->转到项目结构>应用程序>构建>报告在报告中,您将找到错误报告。在任何浏览器中打开它,然后查看错误,然后解决。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.