[英]How to define different compileSdkVersion using productFlavors in app build.gradle in android
I want to add define different compile sdk version for each if my product flavour A and B as mentioned below.如果我的产品风味 A 和 B 如下所述,我想为每个添加定义不同的编译 sdk 版本。
productFlavors {
a{
compileSdkVersion 29
}
b{
compileSdkVersion 30
}
}
But its not detecting.但它没有检测到。 Please help me if anyone knows.
如果有人知道,请帮助我。
As I know you can't have different build.gradle
for product flavors.据我所知,您不能为产品口味提供不同的
build.gradle
。 However you should be able to condition the buildscript
and the compileSdkVersion
.但是,您应该能够调节
buildscript
和compileSdkVersion
。
It is not so clean but you can use something like:它不是那么干净,但你可以使用类似的东西:
buildscript {
repositories {
jcenter()
mavenCentral()
}
if (condition) {
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0+'
}
} else if (condition) {
dependencies {
classpath 'com.amazon.device.tools.build:gradle:1.1.3'
}
}
}
android {
def type="Google"
if (type=="Google") {
compileSdkVersion 29
} else if (type=="Amazon") {
compileSdkVersion 30
}
//...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.