要禁用使用Groovy DSL生成BuildConfig
,可以执行以下操作:
afterEvaluate {
generateReleaseBuildConfig.enabled = false
generateDebugBuildConfig.enabled = false
}
我正在尝试使用Gradle的Kotlin DSL(build.gradle.kts)来寻找等效项。有人有运气吗?
您可以通过添加以下内容从所有变体中删除BuildConfig:
对于图书馆
android {
...
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
libraryVariants.all {
generateBuildConfigProvider?.get()?.enabled = false
}
}
用于申请
android {
...
// TODO replace with https://issuetracker.google.com/issues/72050365 once released.
applicationVariants.all {
generateBuildConfigProvider?.get()?.enabled = false
}
}
如果要指定构建类型,则:
libraryVariants
.matching { it.buildType.name == "release"}
.all {
generateBuildConfigProvider?.get()?.enabled = false
}
}