相关疑难解决方法(0)

如何使用Lint Option StopShip使Grade发布版本失败?

我已经阅读了很多关于StopShipAndroid Lint Check和Gradle支持的内容

我想使用SO中的一些已经提到的,而不是TODO或FIXME注释,使用它来确保用于开发/调试/测试的代码块不能达到生产.

为此,我想做两件事: - 启用StopShip检查,因为它默认是禁用 - 将严重性从警告(默认)更改为错误

(假设我们abortOnError true在gradle配置上使用).

我没能做到这一点!无论我尝试什么,如果我// STOPSHIP在代码中添加注释,android构建都不会失败.这很奇怪,因为在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'
}
Run Code Online (Sandbox Code Playgroud)

我还尝试在"文件">"设置">"项目设置">"检查"(或Android中的Android Studio>"首选项">"检查")中更改我的Android Studio首选项.在这里,我检查Code contains STOPSHIP marker并将严重性更改为错误,但仍然没有.

这是我的lint.xml样子:

<?xml …
Run Code Online (Sandbox Code Playgroud)

android gradle android-lint build.gradle android-gradle-plugin

12
推荐指数
1
解决办法
2027
查看次数