I'm using following configuration:
android {
// a lot more of definitions...
signingConfigs {
// For advanced-artefacts, we are using a different signing configuration in each environment
advanced_prod {
storeFile file(RELEASE_KEYSTORE_FILE_advanced)
storePassword RELEASE_KEYSTORE_PASSWORD_ADVANCED
keyAlias RELEASE_KEY_ALIAS_ADVANCED
keyPassword RELEASE_KEY_PASSWORD_ADVANCED
}
advanced_int {
storeFile file(RELEASE_KEYSTORE_FILE_advanced)
storePassword RELEASE_KEYSTORE_PASSWORD_ADVANCED
keyAlias "advancedapp.android.int"
keyPassword RELEASE_KEY_PASSWORD_ADVANCED
}
advanced_test {
storeFile file(RELEASE_KEYSTORE_FILE_advanced)
storePassword RELEASE_KEYSTORE_PASSWORD_ADVANCED
keyAlias "advancedapp.android.test"
keyPassword RELEASE_KEY_PASSWORD_ADVANCED
}
advanced_dev {
storeFile file(RELEASE_KEYSTORE_FILE_advanced)
storePassword RELEASE_KEYSTORE_PASSWORD_ADVANCED
keyAlias "advancedapp.android.dev"
keyPassword RELEASE_KEY_PASSWORD_ADVANCED
}
basic {
storeFile file(RELEASE_KEYSTORE_FILE_BASIC)
storePassword RELEASE_KEYSTORE_PASSWORD_BASIC
keyAlias RELEASE_KEY_ALIAS_BASIC
keyPassword RELEASE_KEY_PASSWORD_BASIC
storeType "JKS"
}
}
flavorDimensions "project", "environment"
productFlavors {
basic {
dimension "project"
}
advanced {
dimension "project"
}
flavorDevelopment {
dimension "environment"
applicationId "ch.domain.superapp.development"
}
flavorTest {
dimension "environment"
applicationId "ch.domain.superapp.test"
}
flavorIntegration {
dimension "environment"
applicationId "ch.domain.superapp.integration"
}
flavorProduction {
dimension "environment"
applicationId "ch.domain.superapp.production"
}
}
buildTypes {
debug {
testCoverageEnabled true
// all debug artefacts are signed with the default, the android debug certificate from the local machine
}
release {
// Currently all environments (dev/test/int/prod) are signed by the Production certificates either for basic or for advanced
productFlavors.basic.signingConfig signingConfigs.basic
productFlavors.advanced.signingConfig signingConfigs.advanced_prod // <- !!! here my question relates to !!!
}
}
// a lot more of definitions...
}
This configuration will create following build-Variants:
advancedFlavorDevelopmentRelease -> signingConfig: advanced_dev
advancedFlavorTestRelease -> signingConfig: advanced_test
advancedFlavorIntegrationRelease -> signingConfig: advanced_int
advancedFlavorProductionRelease -> signingConfig: advanced_prod
advancedFlavorDevelopmentDebug -> signingConfig: android_debug (local)
advancedFlavorTestDebug -> signingConfig: android_debug (local)
advancedFlavorIntegrationDebug -> signingConfig: android_debug (local)
advancedFlavorProductionDebug -> signingConfig: android_debug (local)
basicFlavorDevelopmentRelease -> signingConfig: basic
basicFlavorTestRelease -> signingConfig: basic
basicFlavorIntegrationRelease -> signingConfig: basic
basicFlavorProductionRelease -> signingConfig: basic
basicFlavorDevelopmentDebug -> signingConfig: android_debug (local)
basicFlavorTestDebug -> signingConfig: android_debug (local)
basicFlavorIntegrationDebug -> signingConfig: android_debug (local)
basicFlavorProductionDebug -> signingConfig: android_debug (local)
My Question is relating to following code:
productFlavors.advanced.signingConfig signingConfigs.advanced_prod
Currently I'm assigning all environments from the advanced Flavor the advanced_prod certificate
the certification need for the basic version is fine and done with above configuration!
I made a trial which was not successful:
applicationVariants.all { variant ->
if (variant.name == 'advancedFlavorDevelopmentRelease') {
def flavor = variant.mergedFlavor
flavor.signingConfig = signingConfigs.advanced_dev;
}
if (variant.name == 'advancedFlavorTestRelease') {
def flavor = variant.mergedFlavor
flavor.signingConfig = signingConfigs.advanced_test;
}
if (variant.name == 'advancedFlavorIntegrationRelease') {
def flavor = variant.mergedFlavor
flavor.signingConfig = signingConfigs.advanced_int;
}
if (variant.name == 'advancedFlavorProductionRelease') {
def flavor = variant.mergedFlavor
flavor.signingConfig = signingConfigs.advanced_prod;
}
}
I'm searching for a solution to customize the advanced Product to configure a dedicated signConfig for each environment (flavorDevelopment/flavorTest/flavorIntegration) but only in release buildType
any Ideas?
Luke
I met the same situation, here is my solution and it works for me.
android {
signingConfigs {
flavorA {
storeFile file("xxx.jks")
storePassword "xxx"
keyAlias "xxx"
keyPassword "xxx"
}
flavorB {
storeFile file("xxx.jks")
storePassword "xxx"
keyAlias "xxx"
keyPassword "xxx"
}
}
productFlavors {
flavorA {
signingConfig signingConfigs.flavorA
}
flavorB {
signingConfig signingConfigs.flavorB
}
}
buildTypes {
release {
minifyEnabled true
proguardFiles 'proguard-rules.pro'
}
debug.init(release.signingConfig)
debug {
minifyEnabled false
}
}
}
And my AndroidStudio is 3.6.2 and AGP is 3.6.2.
Hope it can help you !
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