Android Studio Build Debug Apk With Release Key

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:

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.