I have old apps using non compliant applicationId. I trying to migrate them with flavorDimensions to share so common assets & code. I have this flavors setup :
defaultConfig {
applicationId "com.example"
}
flavorDimensions 'fruit', 'env'
productFlavors {
pear {
dimension 'fruit'
}
banana {
dimension 'fruit'
}
staging {
dimension 'env'
}
prod {
dimension 'env'
}
}
I would like to have these applicationId by flavor combination :
- pearStaging :
com.example.pear_staging
(note the "_") - pearProd :
com.example.pear
- bananaStaging :
com.example.banana_staging
(note the "_") - bananaProd :
com.example.banana
I have tried to use applicationIdSuffix
:
productFlavors {
pear {
dimension 'fruit'
applicationIdSuffix 'pear'
}
banana {
dimension 'fruit'
applicationIdSuffix 'banana'
}
staging {
dimension 'env'
applicationIdSuffix '_staging'
}
prod {
dimension 'env'
}
}
but suffixes are separated with dot by default. So it's generate wrong applicationId, ex:
flavor pearStaging : com.example.pear._staging
(note the "." before "_")
I saw answers on this thread :
How to set different applicationId for each flavor combination using flavorDimensions?
They talk about a workaround using mergedFlavor.setApplicationId(...)
to override applicationId at the end. But this not working if I use in combination with google services gradle plugin.
Because during plugin process phase, I got this error :
* What went wrong:
Execution failed for task ':app:processPearStagingDebugGoogleServices'.
> No matching client found for package name 'com.example'
As you see, it use default applicationId/package name, not the appId overrided in android.applicationVariants.all
phase.
So there is a better way to defined my applicationId per flavor combination that works with google services task ? (I need to keep these applicationId with "_", can't change it).