I have multiple flavourDimensions. I try to sign each resulting variant with a different signingConfig. I'm currently using Gradle 7.5.1 and Android Gradle Plugin 7.4.1.
I've followed the suggested approach from both Google and this StackOverflow answer, as the way to set a custom signingConfig to a variant has changed since AGP 7.1.
Approach:
androidComponents {
onVariants { variant ->
variant.signingConfig?.setConfig(android.signingConfigs.getByName("buildTypeXFlavorA"))
}
}
However, when either doing Build > Build Bundle(s) / APK(s) > Build APK(s) or ./gradlew assemble<variant name>Release I end up with an unsigned APK (<apk name>-unsigned.apk)
Does anyone has the same issue? How can I get the signed APK?
Here is a example of the current configuration:
android {
signingConfigs {
appleRedRelease {
storeFile file("/path_to_file")
keyAlias "the_alias"
storePassword "the_password"
keyPassword "the_key_password"
}
pearYellowRelease {
//...
}
//...
}
buildTypes {
release {
//...
}
}
flavorDimensions "fruit", "color", "version"
productFlavors {
apple {
dimension "fruit"
}
pear {
dimension "fruit"
}
red {
dimension "color"
}
yellow {
dimension "color"
}
free {
dimension "version"
}
paid {
dimension "version"
}
}
}
androidComponents {
onVariants(selector().all(), { variant ->
if (variant.name == "appleRedFreeRelease") {
variant.signingConfig.setConfig(android.signingConfigs.appleRedRelease)
} else {
//...
}
})
}