flavorDimensions "environment"
productFlavors {
prod { dimension "environment" }
qa { dimension "environment" }
dev { dimension "environment" }
}
别忘了给子模块添加依赖项。
我有类似的(最好说更复杂的)情况,它的工作非常大。以下是我的主要/子模块gradle风格示例:
主要内容:
flavorDimensions "brand", "mode"
productFlavors {
// Brand
a {
dimension "brand"
applicationIdSuffix ".a"
}
b{
dimension "brand"
applicationIdSuffix ".b"
}
// Demo-mode
normal {
dimension "mode"
resValue "string", "demo_verion", ""
}
demo {
dimension "mode"
applicationIdSuffix ".demo"
versionNameSuffix "-demo"
resValue "string", "demo_verion", "DEMO VERSION"
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':submodulelib')
}
flavorDimensions "brand"
productFlavors {
// Brand
a{
dimension "brand"
externalNativeBuild {
cmake {
cFlags "-DA"
}
}
}
b{
dimension "brand"
externalNativeBuild {
cmake {
cFlags "-DB"
}
}
}
}