Android Studio Build Debug Apk With Release Key

April 13, 2018

In Android Studio, goto File -> Project Structure -> Modules -> app -> Signing.

Click on the green add(+) button. Leave name as config and fill in Key Alias, Key Password, Store File (*.jks) and Store Password. Click OK to save.

Android Studio Signing

Select the Build Types tab, click on debug and select config for Signing Config.

Android Studio Build Types

Click on Run 'app' as usual to deploy debug app, and the Release Key shall be used instead of the usual Debug Key.

NOTE: You might bump into build error android dependencies signatures are inconsistent. Goto Build -> Clean Project then Rebuild Project.

The above action will generate the following config in Module build.gradle.

android {
    signingConfigs {
        config {
            keyAlias '***'
            keyPassword '***'
            storeFile file('***.jks')
            storePassword '***'
        }
    }

    ...

    buildTypes {
        debug {
            signingConfig signingConfigs.config
        }
        ...
    }
    ...
}    

NOTE: if you are using version control like git, make sure to put your credentials in properties file and prevent commiting them.

References:

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.