在gradle 3之前,我们可以使用
configurations {
client1DevCompile
...
}
dependencies {
client1DevCompile project(
path: ':common',
configuration: 'app1DevRelease'
)
...
}
在gradle 3之后,它声明如果两个模块具有相同的flavorDimensions和productFlavors,则构建变量将自动传播。
在我的主要模块中,
flavorDimensions "environment"
productFlavors {
prod {
applicationId "package"
dimension "environment"
}
qa {
applicationId "package.qa"
dimension "environment"
}
dev {
applicationId "package.dev"
dimension "environment"
}
}
and in sub module i have
flavorDimensions "environment"
productFlavors {
prod { dimension "environment" }
qa { dimension "environment" }
dev { dimension "environment" }
}
答案 0 :(得分:0)
在子模块中,更改如下样式:
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"
}
}
}
}