Debug Signing Config on Gradle Product Flavors

android, build, code-signing, gradle

Solution

Try adding this to your build.gradle. It will specify which `signingConfig` to use for each `flavor` when building the `debug` build type:

buildTypes {
    debug {
        productFlavors.nexus4.signingConfig signingConfigs.nexus4
        productFlavors.nexus7.signingConfig signingConfigs.nexus7
    }
}

Problem

I've got a project where I have several device-specific product flavors, and each flavor needs to be signed with a different config: ``` productFlavors { nexus7 { signingConfig signingConfigs.nexus7 } nexus4 { signingConfig signingConfigs.nexus4 } } ``` This works great when building a 'release' variant. However, when using a 'debug' variant (e.g. when I build Nexus4Debug), Gradle is using the default android debug key. In my case, I'm highly dependent on these builds being signed the right way, and my application is relatively useless if signed with the default debug key. Anyone know if there's a way to specify the signing config for each variant? I know I can do it per build type, a la: ``` buildTypes { debug { signingConfig signingConfigs.nexus4 } } ``` but this limits me to always using the same signing config for debug builds of both flavors. PS - Understand this is a little bit of an edge use case here. This is for an enterprise project where we're testing custom ROMs and system-signed apps on a number of different Nexus devices.

Original source

Related problems