How to create a release signed apk file using Gradle?
android, android-gradle-plugin, apk, gradle, release
Solution
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
Problem
I would like to have my Gradle build to create a release signed apk file using Gradle. I'm not sure if the code is correct or if I'm missing a parameter when doing `gradle build`? This is some of the code in my `build.gradle`/`build.gradle.kts` file: ``` android { ... signingConfigs { release { storeFile(file("release.keystore")) storePassword("******") keyAlias("******") keyPassword("******") } } } ``` The Gradle build finishes SUCCESSFUL, and in my `build/apk` folder I only see the `...-release-unsigned.apk` and `...-debug-unaligned.apk` files. Any suggestions on how to solve this?
Related problems
- Android Studio: how to generate signed APK using Gradle?
- Signing product flavors with gradle
- Gradle build null console object
- Setting environment variables on OS X
- How to use V1 (Jar signature) or V2 (Full APK signature) from build.gradle file
- Gradle build task installRelease missing in Android project
- How can I create a keystore?
- Android studio- adding signing configurations to gradle