我有几种口味,我希望在每个buildType的基础上配置特定资源。
如果只有一种风格,以下配置可以正常工作,android会按预期识别资源目录src / flavor1 / res和src / flavor1 / :: buildType :: / res:
productFlavors {
flavor1 {
applicationId "com.flavor1"
sourceSets {
debug {
res.srcDirs = [ 'src/flavor1/debug/res' ]
}
staging {
res.srcDirs = [ 'src/flavor1/staging/res' ]
}
release {
res.srcDirs = [ 'src/flavor1/release/res' ]
}
}
}
}
但是,如果我添加多个flavor,则无论在Android Studio中当前选择了哪种变体,定义的最后一个flavor的资源目录都是唯一可识别的:
productFlavors {
flavor1 {
applicationId "com.flavor1"
sourceSets {
debug {
res.srcDirs = [ 'src/flavor1/debug/res' ]
}
staging {
res.srcDirs = [ 'src/flavor1/staging/res' ]
}
release {
res.srcDirs = [ 'src/flavor1/release/res' ]
}
}
}
flavor2 {
applicationId "com.flavor2"
sourceSets {
debug {
res.srcDirs = [ 'src/flavor2/debug/res' ]
}
staging {
res.srcDirs = [ 'src/flavor2/staging/res' ]
}
release {
res.srcDirs = [ 'src/flavor2/release/res' ]
}
}
}
}
在上面的配置中,例如,当我选择flavor1Debug时,以下目录被识别为资源目录:
src/flavor1/res
src/flavor2/debug/res
我错过了什么?