我有一些外部库,它们的版本不同以匹配所有我的构建变体。在这个例子中,我有4个不同版本的同一个库。我无法弄清楚如何在我的build.gradle文件中实现这一点。我有两种不同的flavor,与release和debug组合使用。在下面的示例中,被注释的代码可以工作,而其他代码是我想要让其工作的代码。
android {
buildTypes {
release {
minifyEnabled true
}
debug {
minifyEnabled false
}
}
flavorDimensions "base"
productFlavors {
flavor1 {
dimension "base"
applicationIdSuffix ".flavor1"
}
flavor2 {
dimension "base"
applicationIdSuffix ".flavor2"
}
}
}
dependencies {
// this works but cannot specify the build type
flavor1Implementation files('libs/mylib-release.aar')
// this combination of buildType+Flavor is not working
// flavor1ReleaseImplementation files('libs/mylib-flavor1-release.aar')
// flavor1DebugImplementation files('libs/mylib-flavor1-debug.aar')
// this works but cannot specify the build type
flavor2Implementation files('libs/mylib-flavor2-release.aar')
// flavor2ReleaseImplementation files('libs/mylib-flavor2-release.aar')
// flavor2DebugImplementation files('libs/mylib-flavor2-debug.aar')
}