I have the same structure as the code below and I want to put prefix to the applicationId and suffix without dots and use the applicationId value at the end within the gradle file.
I don't want to use applicationIdSuffix because it add dots automatically and I can't get it's value on gradle neither the complete applicationId.
flavorDimensions "type", "version"
productFlavors.all {
ext.appIdPrefix = "com.example"
ext.appId = ""
ext.appIdSuffix = ""
}
productFlavors {
flavor1 {
dimension "type"
appId = ".flavor1"
}
full {
dimension "version"
appIdSuffix = "Full"
}
}
productFlavors.all {
applicationId appIdPrefix + appId + appIdSuffix
}
Now when I run my app with "flavor1full" the applicationId is "com.exmaple.flavor1" only and doesn't get the value of appIdSuffix
How I can solve that ?
Instead of changing app ID for each flavor, try to iterate over applicationVariants:
applicationVariants.all { variant ->
def flavors = variant.productFlavors
variant.mergedFlavor.applicationId = flavors[0].appId + flavors[1].appIdSuffix ;
}
This will iterate through every combination of flavors twice because of the two build types. See also Multi-Dimension Flavor ApplicationId
Also note a typo in your question: appIdSuffix "Full"
should be appIdSuffix="Full"