How to Create a Release Signed Apk File Using Gradle

How to create a release signed apk file using Gradle?

Easier way than previous answers:

Put this into ~/.gradle/gradle.properties

RELEASE_STORE_FILE={path to your keystore}
RELEASE_STORE_PASSWORD=*****
RELEASE_KEY_ALIAS=*****
RELEASE_KEY_PASSWORD=*****

Modify your app/build.gradle, and add this inside the android { code block:

...    
signingConfigs {

release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD

// Optional, specify signing versions used
v1SigningEnabled true
v2SigningEnabled true
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}
....

Then you can run gradle assembleRelease


Also see the reference for the signingConfigs Gradle DSL

Android Studio: how to generate signed APK using Gradle?

There are three ways to generate your build as per the buildType. (In your case, it's release but it can be named anything you want.)

  1. Go to Gradle Task in right panel of Android Studio and search for assembleRelease or assemble(#your_defined_buildtype) under Module Tasks

  2. Go to Build Variant in Left Panel and select the build from drop down

  3. Go to project root directory in File Explore and open cmd/terminal and run:

    Linux: ./gradlew assembleRelease or assemble(#your_defined_buildtype)

    Windows: gradlew assembleRelease or assemble(#your_defined_buildtype)

If you want to do a release build (only), you can use Build > Generate Signed apk. For other build types, only the above three options are available.

You can find the generated APK in your module/build directory having the build type name in it.

android studio, how to make signed apk for release build (gradle using KTS build files)

lol, it should work but need to delete the one installed before.

How to create a release signed apk file using Gradle?

Easier way than previous answers:

Put this into ~/.gradle/gradle.properties

RELEASE_STORE_FILE={path to your keystore}
RELEASE_STORE_PASSWORD=*****
RELEASE_KEY_ALIAS=*****
RELEASE_KEY_PASSWORD=*****

Modify your app/build.gradle, and add this inside the android { code block:

...    
signingConfigs {

release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD

// Optional, specify signing versions used
v1SigningEnabled true
v2SigningEnabled true
}
}

buildTypes {
release {
signingConfig signingConfigs.release
}
}
....

Then you can run gradle assembleRelease


Also see the reference for the signingConfigs Gradle DSL



Related Topics



Leave a reply



Submit