How to create a release signed apk file using Gradle?

Once your android application is ready, You need to generate apk with signed.

This tutorial talks about how to generate a release apk file using Gradle file.

create a release signed apk file using Gradle

How to generate release unsigned apk file using Gradle?

During development, You need to test your application on real devices, you need to generate an unsigned apk file.

Here are sequence of steps to generate unsigned apk release In build.gradle file, You can add signingConfigs attribute with below values.

        storePassword = ""
        keyAlias = ""
        keyPassword = ""

Next, add buildTypes with release information.

        signingConfig signingConfigs.unsigned

Next, run the below commands

Gradle build
gradle assemble

It generates apk name project-release-unsigned.apk file under `appmodule/build/outputs/apk/

How to create android app signed apk released using Gradle

For signing and releasing an apk file, We need the following things.

  • keyAlias: alias key
  • keyPassword: the key to sign a password
  • storePassword: actual password
  • storeFile: Keystore file
  • v1SigningEnabled: jar file signing
  • v2SigningEnabled: complete apk signing

This example configure static values in build.gradle Add all this under release property in signingConfigs of build.gradle file

signingConfigs {
            release {
                keyAlias 'alias key'
                keyPassword 'key password'
                storePassword 'store Password'
                storeFile file("${directory}/releaseversion.keystore")
                v1SigningEnabled true
                v2SigningEnabled true



Next add the below signingConfig under buildTypes section

buildTypes {
    release {
        signingConfig signingConfigs.release

Next, rebuild your project with the Gradle command

gradle clean build

It generates a signed release apk file and is ready to push to the google play store.

How to read signing keystore from a properties file and generate signed release apk in Gradle

First, We have a properties file release. properties in the config folder of your project

add the below properties to release.properties

storeFile=location of Keystore file

The values are placeholders, So update with your real values.

Add your application build gradle file to read this properties file

def releaseFile = rootProject.file("../../release.properties")
def properties = new Properties()
properties.load(new FileInputStream(releaseFile))

And configure signingConfigs with values read from a properties file

android {

    signingConfigs {
            release {
                keyAlias properties['keyAlias']
                keyPassword properties['keyPassword']
                storeFile file(properties['storeFile'])
                storePassword properties['storePassword']
    buildTypes {
        release {
            signingConfig signingConfigs.release

Run Gradle command to rebuild and generate API file.

gradle clean build


You learned how to generate android app apk in android studio Gradle build

  • signed release apk
  • unsigned release apk
Join 6,000 subscribers and get a daily digest of full stack tutorials delivered to your inbox directly.No spam ever. Unsubscribe any time.

Similar Posts
You'll get a notification every time a post gets published here.