Wednesday, March 30, 2016

Sign Android apk using gradle.


1. With Android Studio create a new release key.
***Save android.kesytore in a safe place and don't forget the password.

2. Put this into ~/.gradle/gradle.properties
RELEASE_STORE_FILE=/../PathToYour/keystore
RELEASE_STORE_PASSWORD=*****
RELEASE_KEY_ALIAS=*****
RELEASE_KEY_PASSWORD=*****
Modify your build.gradle like this: 
...
signingConfigs {

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

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

3. Then in terminal run: $./gradlew assembleRelease
4. Done. Now you have a signed apk that is ready to publish to the android play store.
$cd MyApp/app/build/outputs/apk/app-release.apk


Check who sign the apk with keystone info:
$jarsigner -verify -verbose -certs myApp.apk

Resources:

No comments:

Post a Comment