11

我正在使用Android Studio 2.0,并且在尝试运行我的程序时发生了一些奇怪的事情。我运行了gradle的build命令,并且出现了这个错误:Gradle build:执行失败的任务':app:lint'

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'. 

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

请救我吧!

+0

你在发布吗? –

+0

我很抱歉,但我不知道“build in release”中的含义是什么......你能更具体吗? – Davide

+0

您是使用构建类型“Debug”还是“Release”? –

回答

15

build.gradle

android { 
    lintOptions { 
     abortOnError false 
    } 
} 
+3

我明白了,但我一直在寻找错误的原因......为什么会出现? – Davide

+8

关闭lint就像关闭你的检查引擎指示灯... – MinaHany

+0

对于更多的用户,请确保你在*你的项目中引用了正确的'build.gradle' * - https://stackoverflow.com/questions/37250493/could-not-find-method-android-for-arguments – eouw0o83hf

8

你有一些皮棉的问题,而你是在bulding的应用模块添加此。

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

app\build.gradle

android { 
    lintOptions { 
     abortOnError false 
    } 
} 

使用这个脚本,您可以禁用块,但它是不是最好的做法
您应该分析lint报告以解决每个问题。

+2

感谢您指出报告。但为什么这些警告并未集成到Android Studio?我认为这个IDE比ADT好得多。 – OneWorld

+0

您应该指定短脚本添加您的建议,属于build.gradle的Module:app部分。 –

+0

@Peter是否足够downvote答案? –

2

的build.gradle(模块:APP)应包括


android { 
    lintOptions { 
     abortOnError false 
    } 
} 

4

我觉得这是更好地找到错误,而不是忽略它们。

试试这个:

在摇篮控制台中找到“写HTML报告文件”,打开指定的HTML文件,你会发现一个线头报告

转到你的错误和解决这些问题

HTML lint report

0

运行gradle build -i而不是仅仅gradle build。将会有比平常更多的产出。其中一些看起来像这样:

> Task :project-name:lint FAILED 
Putting task artifact state for task ':project-name:lint' into context took 0.0 secs. 
Up-to-date check for task ':project-name:lint' took 0.0 secs. It is not up-to-date because: 
    Task has not declared any outputs. 
Ran lint on variant release: 333 issues found 
Ran lint on variant debug: 333 issues found 
Wrote HTML report to file:///some/path/lint-results.html 
Wrote XML report to file:///some/pahth/lint-results.xml 

:project-name:lint (Thread[Task worker for ':',5,main]) completed. Took 1.756 secs. 

退房/some/path/lint-results.html明白为什么皮棉失败。一旦这些错误得到解决,你的构建就会顺利完成。

0
  1. 切换到项目视图
  2. 然后,项目/应用程序/编译/报告/棉绒的结果
  3. 现在,你会发现掉毛的结果文件有两种格式 - 1)XML和2)HTML 。

您可以按原样查看这些文件。但是,我发现在浏览器中查看绒毛效果很容易。只需右键单击该html文件并选择浏览器中的视图。

对我来说,这是一个布局属性错误。

Screenshot of lint results

相关问题