DEV Community

Cristopher Coronado
Cristopher Coronado

Posted on

Create key store and sign APK manually

In this article, we will learn how to create a release key store for Android app and then sign it.

Requirements:

1. Create private keystore

Make sure keytool command is global available (You can find in C:\Program Files (x86)\Java\jdk1.8.0_181\bin).

image



keytool -genkeypair -v -keystore <RELEASE_KEY_PATH> -alias <RELEASE_KEY_ALIAS> -keyalg RSA -keysize 2048 -validity 10000  


Enter fullscreen mode Exit fullscreen mode

Example:

image

2. Apply zipalign

The zipalign file alignment tool makes it possible to greatly optimize Android application (APK) files.
I have Android Studio installed, so my Android SDK location is C:\Program Files (x86)\Android\android-sdk.
You have to use the latest Android SDK installed path. In my case is C:\Program Files (x86)\Android\android-sdk\build-tools\27.0.3.
The APK_UNSIGNED_PATH is a Release APK.



zipalign -f -v 4 <APK_UNSIGNED_PATH> <APK_PATH>


Enter fullscreen mode Exit fullscreen mode

image

3. Sign APK

In the same path from step 2.



apksigner sign --ks <RELEASE_KEY_PATH> --ks-key-alias <RELEASE_KEY_ALIAS> <APK_SIGNED_PATH>


Enter fullscreen mode Exit fullscreen mode

Verify signature in APK:



apksigner verify <APK_SIGNED_PATH>


Enter fullscreen mode Exit fullscreen mode

If everything is correct you won't see errors in the console.

Thanks for reading

Thank you very much for reading, I hope you found this article interesting and may be useful in the future. If you have any questions or ideas that you need to discuss, it will be a pleasure to be able to collaborate and exchange knowledge together.

Top comments (0)