Skip to content

Instantly share code, notes, and snippets.

@StephaneBg
Last active December 15, 2021 21:17
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save StephaneBg/23476891fb37f80f9dc3e7bddade7c79 to your computer and use it in GitHub Desktop.
Save StephaneBg/23476891fb37f80f9dc3e7bddade7c79 to your computer and use it in GitHub Desktop.
Set different signing configs with multiple flavors and dimensions
signingConfigs {
vanillaPaid {
...
}
vanillaFree {
...
}
chocolatePaid {
...
}
chocolateFree {
...
}
}
flavorDimensions "taste", "type"
productFlavors {
vanilla {
dimension "taste"
applicationIdSuffix ".vanilla"
}
chocolate {
dimension "taste"
applicationIdSuffix ".chocolate"
}
free {
dimension "type"
...
}
paid {
dimension "type"
...
}
}
applicationVariants.all { variant ->
if (variant.name.equals("vanillaPaidRelease")) {
variant.mergedFlavor.setSigningConfig(signingConfigs.vanillaPaid)
} else if (variant.name.equals("vanillaFreeRelease")) {
variant.mergedFlavor.setSigningConfig(signingConfigs.vanillaFree)
} else if (variant.name.equals("chocolatePaidRelease")) {
variant.mergedFlavor.setSigningConfig(signingConfigs.chocolatePaid)
} else if (variant.name.equals("chocolateFreeRelease")) {
variant.mergedFlavor.setSigningConfig(signingConfigs.chocolateFree)
}
}
buildTypes {
release {
...
}
debug {
...
}
}
@nestoleh
Copy link

nestoleh commented Oct 5, 2018

Hi! Is this solution still working? Because in my case I always get unsigned apk-file.

@maxim-petlyuk
Copy link

Hi! Is this solution still working? Because in my case I always get unsigned apk-file.

I can confirm. It doesn`t work.

@dennisvdzalm
Copy link

Have been struggling with setting signingconfigs based on merged flavors for a while now. Can confirm Gradle outputs an apk file with the unsigned name suffix using this approach. But, the APK itself is actually signed. So this solution does work, only the output file name is incorrect.

@MBratkowski
Copy link

It doesn't work - I received unsigned apk, and validate by jarsinger I received information that apk it is not signed.

@jemshit
Copy link

jemshit commented Apr 1, 2020

Only getters exists in kotlin-gradle on mergedFlavor :/

@belinwu
Copy link

belinwu commented Dec 3, 2020

Not working for me when using Android Studio 4.0+
Is working for me when using Android Studio 3.6

@jemshit
Copy link

jemshit commented Dec 3, 2020

@iit2008047
Copy link

any lead ? stuck with this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment