Gradle build:任务执行失败':app:lint'

Dav*_*ide 25 android gradle android-studio android-gradle-plugin android-studio-2.0

我正在使用Android Studio 2.0,当发生奇怪的事情时,我正试图运行我的程序.我运行了gradle的build命令,我收到了这个错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:lint'.
> Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
    lintOptions {
        abortOnError false
    }
}
...

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

BUILD FAILED

Total time: 4.197 secs
Lint found errors in the project; aborting build.

Fix the issues identified by lint, or add the following to your build script to proceed with errors:
...
android {
    lintOptions {
        abortOnError false
    }
}
...
10:41:28: External task execution finished 'build'.
Run Code Online (Sandbox Code Playgroud)

所以...到底是什么意思?我应该这样做来解决这个问题,将代码添加到gradle.build,但问题是:为什么我收到此错误消息?

请救救我们!

Pin*_*nks 31

将此添加到您的 build.gradle

android {
    lintOptions {
        abortOnError false
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 我明白了,但我一直在寻找错误的原因......为什么会出现? (6认同)

Gab*_*tti 18

在构建应用程序模块时,您会遇到一些lint问题.

您可以在中生成的报告中找到所有问题Project\module\build\outputs.
在这里,您将找到带有lint报告的html文件和xml文件.

在中使用此脚本 app\build.gradle

android {
    lintOptions {
        abortOnError false
    }
}
Run Code Online (Sandbox Code Playgroud)

您可以禁用该块,但这不是最佳做法.
您应该分析lint报告以解决每个问题.

  • 感谢您指出该报告.但为什么不将这些警告集成到Android Studio中?我认为这个IDE比ADT好多了. (4认同)

Avi*_*mer 11

  1. 切换到项目视图
  2. 然后,project/app/build/reports/lint-results
  3. 现在,您将找到两种格式的lint-result文件 - 1)xml和2)html.

您可以按原样查看这些文件.但是,我发现在浏览器中查看lint结果很容易.只需右键单击html文件,然后在浏览器中选择视图即可.

它会在我的Chrome浏览器中打开,如下图所示.

lint结果的屏幕截图

  • 而不是忽视。这是正确的方法,可以解决。 (2认同)

Jor*_*any 8

我认为找到错误而不是忽略错误会更好.

试试这个:

在Gradle Console中找到"将HTML报告写入文件 ",打开指定的HTML文件,您将找到一份棉绒报告

转到您的错误并修复它们

HTML lint报告