更新时间:2023-09-13 20:28:10
是 0.7.0 总会有扩展支持,林特,然而,它并不总是正常工作。 (例如,在butterknife库)
With 0.7.0 there comes extended support for Lint, however, it does not work always properly. (Eg. the butterknife library)
解决办法是禁用中止基础上发现皮棉错误
Solution is to disable aborting build on found lint errors
我把灵感来自于 https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7
(执行: https://android.googlesource.com/platform/tools/base/+/e6a5b9c7c1bca4da402de442315b5ff1ada819c7/build-system/gradle/src/main/groovy/com/android/build/gradle/internal/model/DefaultAndroidProject.java )
(讨论:https://plus.google.com/+AndroidDevelopers/posts/ersS6fMLxw1 )
android {
// your build config
defaultConfig { ... }
signingConfigs { ... }
compileOptions { ... }
buildTypes { ... }
// This is important, it will run lint checks but won't abort build
lintOptions {
abortOnError false
}
}
如果你需要禁用只是特定的皮棉规则,并保持在构建失败的人,用这个:
/*
* Use only 'disable' or only 'enable', those configurations exclude each other
*/
android {
lintOptions {
// use this line to check all rules except those listed
disable 'RuleToDisable', 'SecondRuleToDisable'
// use this line to check just listed rules
enable 'FirstRuleToCheck', 'LastRuleToCheck'
}
}