How to make Grade release build fail using Lint Option StopShip?
我已经阅读了很多有关
- http://tools.android.com/tips/lint-checks
- http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Lint-support
- http://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.LintOptions.html#com.android.build.gradle.internal.dsl.LintOptions:checkReleaseBuilds
- Android Lint使用Gradle启用检查
- gradle构建失败在皮棉任务上
- http://developer.android.com/tools/help/lint.html
- http://developer.android.com/tools/debugging/improving-w-lint.html
我想使用SO此处已经提到的一些内容,而不是TODO或FIXME注释,而是使用它来确保用于开发/调试/测试的代码块不生产。
为此,我想做两件事:
-启用StopShip检查,因为默认情况下它处于禁用状态
-将严重性从警告(默认)更改为错误
(假设我们在gradle配置中使用
我无法实现这一目标!如果我在代码中添加
这是我在
1 2 3 4 5 6 7 8 | lintOptions { checkReleaseBuilds true // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError true enable 'StopShip' error 'StopShip' } |
我还尝试在"文件">"设置">"项目设置">"检查"(或在Mac上," Android Studio">"首选项">"检查")中更改我的Android Studio首选项。在这里,我检查了
这是我的
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?xml version="1.0" encoding="UTF-8"?> <lint> <issue id="BackButton" severity="warning" /> <issue id="EasterEgg" severity="warning" /> <issue id="FieldGetter" severity="warning" /> <issue id="IconExpectedSize" severity="warning" /> <issue id="RtlCompat" severity="error" /> <issue id="RtlEnabled" severity="warning" /> <issue id="RtlHardcoded" severity="warning" /> <issue id="SelectableText" severity="warning" /> <issue id="StopShip" severity="error" /> <issue id="TypographyQuotes" severity="warning" /> <issue id="UnusedIds" severity="warning" /> </lint> |
我终于破解了!
在我的
我不完全理解为什么以前使用
Whether lint should set the exit code of the process if errors are found
并且我将
当然,如果有人提供更好的解决方案/解释,请分享。