【发布时间】:2021-08-18 07:06:08
【问题描述】:
我有一些不同版本的外部库来匹配我所有的构建变体。在这个例子中,我有同一个库的 4 个不同版本。我无法在我的 build.gradle 文件中弄清楚如何做到这一点。我有两种不同的风格,结合了发布和调试。在下面的示例中,注释掉的代码可以工作,而其他代码是我正在尝试的工作。
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')
}
【问题讨论】:
标签: android gradle build variant