我有将用于多个客户的 Gradle Android 项目。它还将有免费和付费版本。我意识到可以通过使用 flavorDimensions 来实现。但问题是我想有一种方法来根据所选口味生成包名称。
flavorDimensions 'branding', 'version'
productFlavors {
free {
flavorDimension 'version'
}
paid{
flavorDimension 'version'
}
customer1 {
flavorDimension 'branding'
}
customer2 {
flavorDimension 'branding'
}
}
// pseudocode
def getGeneratePackageName() {
if (customer1 && free) {
return 'com.customer1.free'
}
if (customer2 && free) {
return 'com.customer2.free'
}
if (customer1 && paid) {
return 'com.customer1.paid'
}
if (customer2 && paid) {
return 'com.customer2.paid'
}
}
我想知道我什么时候需要调用这个方法,我需要设置什么变量?