This tutorial shows how to create a signed release APK of your project with AndroidIDE.
This tutorial covers the following topics :
Create a keystore file with AndroidIDE Terminal.
Configure Gradle to use the signing key.
Verify APK signature.
Creating the keystore
For creating the keystore file, we’ll use
keytool that is provided by OpenJDK. You can execute the
command to check if the tool is available or not. If you do not see the help message, you might need
to perform the basic setup before you can proceed
with next steps.
Open the terminal and follow the instructions to create the keystore.
First of all, you need to
cd into the directory where you want to store the keystore file. For this tutorial, we’ll be
storing the keystore in the
AndroidIDEProjects directory in the internal storage. Execute the following command
cd into the projects’ directory :
PROJECTS is an environment variable whose value is the absolute path of the projects’ directory.
To create a new keystore file, execute the following command :
keytool -genkey -v -keystore signing-key.jks -keyalg RSA -keysize 2048 -validity 9125 -alias myAlias
-genkey: Command used to create new keystore with
-v: For verbose output.
-keystore signing-key.jks: Specifies the filename of the output keystore file. In this example, the keystore file will be saved as
-keyalg RSA: Specifies the key algorithm to use for the keystore.
-keysize 2048: The number of bits in the key used by the key algorithm.
-validity 9125: The validity of the key, in days. In this example, the value is
9125 dayswhich is equal to
-alias myAlias: The key alias.
Learn more about
After you execute the above command, you’ll be asked to provide additional information about the keystore. After you enter the required information, the keystore file will be created.
We need to add
signingConfig in the
app/build.gradle file. The
signingConfig specifies the keystore which will be
used to sign the build variants of your application. To do this, we need to copy the
signing-config.jks file to
app module’s directory of our project. So go ahead and copy the file.
Then edit your
app/build.gradle file like this :
// Specify the name of your keystore file
// The file must be located in your module directory
// The keystore password
// The key alias, same as the one you specified with '-alias' argument while creating the keystore
// The key password
// specify the signingConfig to use for release build type
That’s it! You can now run
:app:assembleRelease task to assemble the release build of your project. The resultant APK
will be signed with the
Verify APK Signature
You can use the
apksigner tool provided by the Android SDK Build Tools to verify the signature of the APK. To do this,
just execute the following command :
$HOME/android-sdk/build-tools/<build-tools-version>/apksigner verify --print-certs /path/to/your/app.apk
# For example
$HOME/android-sdk/build-tools/33.0.3/apksigner verify --print-certs $PROJECTS/MyApplication/app/build/outputs/apk/release/app-release.apk
This will print the information about the APK’s signature. You can learn more about the