Skip to content

Instantly share code, notes, and snippets.

@StephaneBg
Last active December 15, 2021 21:17
Show Gist options
  • Select an option

  • Save StephaneBg/23476891fb37f80f9dc3e7bddade7c79 to your computer and use it in GitHub Desktop.

Select an option

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 {
...
}
}
@maxim-petlyuk

Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown

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

@jemshit

jemshit commented Apr 1, 2020

Copy link
Copy Markdown

Only getters exists in kotlin-gradle on mergedFlavor :/

@belinwu

belinwu commented Dec 3, 2020

Copy link
Copy Markdown

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

@jemshit

jemshit commented Dec 3, 2020

Copy link
Copy Markdown

@iit2008047

Copy link
Copy Markdown

any lead ? stuck with this issue

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