Android Studio 中不同构建类型的不同 lint.xml? [英] Different lint.xml for different build types in Android Studio?
问题描述
我想在 Android Studio 中为 release 和 debug 构建类型使用不同的 lint.xml 文件.那么,如何才能做到这一点?
I want to use different lint.xml files for release and debug build types in Android Studio. So, how can this be achieved?
当我将 lint.xml 放在 someModule/src/debug 和 someModule/src/release 文件夹中时(同样,这些文件夹只包含lint.xml 文件,仅此而已)gradle 反应,因为没有任何 lint.xml 文件,如果我放置单个 lint.xml 文件在核心模块文件夹 (someModule/) 下 - gradle 识别它,但在这种情况下,我不能根据构建类型使用不同的设置...
When I place lint.xml in someModule/src/debug and someModule/src/release folders (also, these folders contain only that lint.xml file and nothing more) gradle reacts as there is no any lint.xml file, If I place single lint.xml file under core module folder (someModule/)- gradle recognizes it, but in this case I can't use different settings depending on build type...
推荐答案
这对我有用:
tasks.whenTaskAdded { task ->
if (task.name.startsWith("lint")) {
if (task.name.toLowerCase().endsWith("release")) {
task.doFirst {
android.lintOptions.abortOnError = true
}
} else {
task.doFirst {
android.lintOptions.abortOnError = false
}
}
}
}
在我的情况下,我需要为发布版本打开 abortOnError
以便我可以自由开发,但在我的 CI 上快速捕获 lint 错误(如果它们滑倒了).
In my case I needed to turn on abortOnError
for release builds so that I can develop freely but catch lint errors quickly on my CI (if they slipped).
这篇关于Android Studio 中不同构建类型的不同 lint.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!