我已经阅读了很多关于 StopShip
Android Lint Check和Gradle支持它
- 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检查
- lint任务上的gradle构建失败
- http://developer.android.com/tools/help/lint.html
- http://developer.android.com/tools/debugging/improving-w-lint.html
我想使用SO中的一些已经提到的,而不是TODO或FIXME注释,使用它来确保用于开发/调试/测试的代码块不能达到生产。
为此,我想做两件事: - 启用StopShip检查,因为它默认是禁用的 - 将严重性从警告(默认)更改为错误
(假设我们使用 abortOnError true
在我们的gradle配置上)。
我没能做到这一点!无论我尝试什么,如果我添加一个,Android构建不会失败 // STOPSHIP
在我的代码中评论。这很奇怪,因为在textEditor中它突出显示为错误,如果我运行Lint检查(Analyze> Inspect Code ...),它将被列为问题之一。
这是我在我的尝试 build.gradle
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'
}
我还尝试在文件>设置>项目设置>检查(或Android中的Android Studio>首选项>检查)中更改我的Android Studio首选项。我在这里查了一下 Code contains STOPSHIP marker
并将严重性更改为错误但仍然没有。
这是我的 lint.xml
好像:
<?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>