I have an app where I need to be able to build apk files for testing, and aab files for uploading to the play store. The apk and aab files should be signed with different keys.
How can I specify different signingConfig blocks depending on whether the build is run with assembleRelease vs. bundleRelease? It seems like this should be a flavor-like thing but I can't figure out how.
You can create a new build type say "store" in addition to "debug" and "release", and give the store build type the required signing config:
android {
buildTypes {
register("store") {
initWith(buildTypes["release"])
matchingFallbacks.add("release")
signingConfig = signingConfigs.create("store") {
...
}
}
}
}
Then:
./gradlew :app:assembleRelease :app:bundleStore
From https://developer.android.com/studio/build/build-variants (emphasis mine):
For example, a "demo" product flavor can specify different features and device requirements, such as custom source code, resources, and minimum API levels, while the "debug" build type applies different build and packaging settings, such as debug options and signing keys.
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