In release mode, you sign your app with your own certificate:
Add the signing configuration to the build file for the app
module:
... android { ... defaultConfig { ... } signingConfigs { release { storeFile file("myreleasekey.keystore") storePassword "password" keyAlias "MyReleaseKey" keyPassword "password" } } buildTypes { release { ... signingConfig signingConfigs.release } } } ...
assembleRelease
build task from Android Studio. The package in app/build/apk/app-release.apk
is now signed with your release key.
Note: Including the passwords for your release key and keystore inside the build file is not a good security practice. Alternatively, you can configure the build file to obtain these passwords from environment variables or have the build process prompt you for these passwords.
To obtain these passwords from environment variables:
storePassword System.getenv("KSTOREPWD") keyPassword System.getenv("KEYPWD")
To have the build process prompt you for these passwords if you are invoking the build from the command line:
storePassword System.console().readLine("\nKeystore password: ") keyPassword System.console().readLine("\nKey password: ")
After you complete this process, you can distribute your app and publish it on Google Play.
Warning: Keep your keystore and private key in a safe and secure place, and ensure that you have secure backups of them. If you publish an app to Google Play and then lose the key with which you signed your app, you will not be able to publish any updates to your app, since you must always sign all versions of your app with the same key.
The rest of this document provides detailed instructions about how to generate a private key and sign your apps in release mode with Android Studio.