I use taste options in my project and I used the for loop to install the application for my generated flavors:
flavorDimensions "appname", "brand" productFlavors { user { dimension "appname" } installer { dimension "appname" } branda { dimension "brand" } brandb { dimension "brand" } brandc { dimension "brand" } brandd { dimension "brand" } }
I filter those that I donโt support right now:
variantFilter { variant -> def names = variant.flavors*.name if (names.contains("installer") && (names.contains("brandc") || names.contains("brancd")) ) { variant.ignore = true } }
Then I update the application by the name of the fragrance:
applicationVariants.all { variant -> def flavorString = variant.getVariantData().getVariantConfiguration().getFlavorName() def mergedFlavour = variant.getVariantData().getVariantConfiguration().getMergedFlavor(); switch (flavorString) { case "userBranda": mergedFlavour.setApplicationId("com.mycompany.product.user.someName") mergedFlavour.setVersionName("1.0.0") break case "userBrandb": mergedFlavour.setApplicationId("com.mycompany.product.user.b") mergedFlavour.setVersionName("2.0.0") break case "userBrandc": mergedFlavour.setApplicationId("com.mycompany.product.user.otherName") mergedFlavour.setVersionName("1.5.0") break case "userBrandd": mergedFlavour.setApplicationId("com.mycompany.product.user.d") mergedFlavour.setVersionName("1.0.1") break case "installerBranda": mergedFlavour.setApplicationId("com.mycompany.product.installer.marketingName") mergedFlavour.setVersionName("1.0.0") break case "installerBrandb": mergedFlavour.setApplicationId("com.mycompany.product.installer.b") mergedFlavour.setVersionName("1.0.0") break default: throw new GradleException("flavor ${flavorString} is not supported, please configure it first...") break }
I have two questions:
1 . Is it correct? Does the android plugin not support the way to configure an application using flavor attributes?
2 . The configuration that I mention here works in most cases, except, for example, if you use google-services.json, which already has an application package. For easy use of the product, Flavor configuration works fine, but if I use flavor sizes, gradle always complains:
:app:processUserBrandaDebugGoogleServices No matching client found for package name 'com.mycompany.product'
Basically, "com.mycompany.product" is the package that is defined by default in AndroidManifest.xml. If I look in
app/build/intermediates/manifests/full/userBranda/debug/AndroidManifest.xml
I see that the package has been successfully replaced.
What I can conclude from this is that only for flavor parameters, somehow gradle combines the manifests only after processUserBrandaDebugGoogleServices, which means that at this point the package defined in the manifest is still the default value.
Anyone with the same problem here? How to solve this problem? Is this an android gradle plugin error?