我正在使用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'.
所以......那到底是什么意思?我应该这样做来解决这个问题,将代码添加到gradle.build,但问题是:为什么我收到此错误消息?
请救救我们!
答案 0 :(得分:26)
在build.gradle
android {
lintOptions {
abortOnError false
}
}
答案 1 :(得分:16)
在建立应用模块时,您会遇到一些棉绒问题。
您可以在Project\module\build\outputs
中找到生成的报告中发现的所有问题
在这里,您将找到带有lint报告的html文件和xml文件。
在app\build.gradle
android {
lintOptions {
abortOnError false
}
}
您可以停用该块,但不是最佳做法。
您应该分析lint报告以解决每个问题。
答案 2 :(得分:11)
答案 3 :(得分:8)
答案 4 :(得分:4)
您的 build.gradle(模块:应用)应包含
android {
lintOptions {
abortOnError false
}
}
答案 5 :(得分: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
以了解lint失败的原因。修复这些错误后,您的构建将顺利完成。
答案 6 :(得分:0)
我收到了错误Execution failed for task ':app:lintVital[myBuildVariant]'
和nullpointer错误。它发生在切换分支之后,对我有帮助的是做 Build - >清洁项目
答案 7 :(得分:0)
仅将此代码添加到build gradle中:
android {
lintOptions {
abortOnError false
}
}
那应该足够了。
答案 8 :(得分:0)
如果您遇到此问题,请不要在gradle中添加linter禁用程序, 这是一个访问错误问题,我在使用sudo命令执行一些命令后遇到了react-native问题, 只需重置您的代码访问权限,然后再次释放 例如mac
sudo chmod -R 777 <project-root-folder-name>
如果仍然使用
preBuild.doFirst {
ant.replaceregexp(
match:'Bad gradle',
replace:'Correct one',
flags:'g',
byline:true
) {
fileset(
dir: 'Where to search',
includes: '*.java'
)
}
}
因此,如果该库中存在该库,则可以在发布前修复错误