I'm trying to figure out how can I specify a signingConfig
for the individual flavor dimensions generated. I have seen how to do it when using different flavor but not flavor dimensions.
I'm currently applying a different package name for the different flavor dimensions successfully and thought maybe something similar could be done with signingConfig
?
> android.applicationVariants.all { variant ->
> def flavorString = variant.getVariantData().getVariantConfiguration().getFlavorName()
> def mergedFlavour = variant.getVariantData().getVariantConfiguration().getMergedFlavor();
>
> if(flavorString.equalsIgnoreCase("amazonFree")) {
> mergedFlavour.setApplicationId("com.test.amazon.free")
> }
> if(flavorString.equalsIgnoreCase("amazonPro")) {
> mergedFlavour.setApplicationId("com.test.amazon.pro")
> }
> if(flavorString.equalsIgnoreCase("googleFree")) {
> mergedFlavour.setApplicationId("com.test.google.free")
> }
> if(flavorString.equalsIgnoreCase("googlePro")) {
> mergedFlavour.setApplicationId("com.test.google.pro")
> } }
My flavor setup
// Special flavor dimensions for different markets and // versions paid and free. flavorDimensions 'market', 'version' productFlavors { amazon { flavorDimension 'market' } google { flavorDimension 'market' } // Base free version free { flavorDimension 'version' // Need this cause of all the ad libraries we are using :/ defaultConfig.multiDexEnabled true // For now we sign all free versions with this config // cause we have no idea how to sign the individual flavor dimensions. signingConfig signingConfigs.googleFree } // Base pro version pro { flavorDimension 'version' // For now we sign all free versions with this config // cause we have no idea how to sign the individual flavor dimensions. signingConfig signingConfigs.googlePro } }
Flavor dimensions are groupings of product flavors, and you can combine flavors from different dimensions.
123 let's go Simply put, a product flavor is a variant of your app. It is very useful when you want to create multiple versions of your app. This means you can generate different versions or variants of your app using a single codebase.
You can add a config file, say 'Appconfig. java' to your productFlavor specific source folders i.e. src/<productflavor>/java/<packagename>/Appconfig. java ; you can then use Appconfig. PRODUCT_FLAVOR in your app.
There is no direct way to get the current flavor; the call getGradle().
First of all applicationId can be applied in productFlavors
block itself:
productFlavors {
amazonFree {
applicationId 'com.test.amazon.free'
}
amazonPro {
applicationId 'com.test.amazon.pro'
}
googleFree {
applicationId 'com.test.google.free'
}
googlePro {
applicationId 'com.test.google.pro'
}
}
Signing config can be configured per flavor the same way:
productFlavors {
amazonFree {
applicationId 'com.test.amazon.free'
signingConfig signingConfigs.amazonFree
}
amazonPro {
applicationId 'com.test.amazon.pro'
signingConfig signingConfigs.amazonPro
}
googleFree {
applicationId 'com.test.google.free'
signingConfig signingConfigs.googleFree
}
googlePro {
applicationId 'com.test.google.pro'
signingConfig signingConfigs.googlePro
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With