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 (4)

Collapse
 
johnsy profile image
rozy ily

Awesome guide on manually signing APKs! This method is crucial for maintaining the security and integrity of Android apps. If you're looking for a secure cloud solution to store your app builds or APK files, Terabox Mod APK offers extra storage space. Check it out here: teraboxapkspro.com/.

Collapse
 
amelia_james_b87f48b56240 profile image
Amelia James

This guide on signing APKs manually is excellent! It’s an essential step to ensure the integrity and security of your Android applications. If you’re looking for a reliable cloud solution to store your app builds or APK files, [dlloklok.com ](url)is a great choice.

Collapse
 
lily_rose_98ea4f0daa3e03d profile image
Lily Rose

Great guide on signing APKs manually! This process really ensures the integrity and security of your Android apps. For anyone storing their app builds or looking for a safe cloud solution for their APKs, Terabox Mod APK is a great option for additional storage. Check it out here: teraboxmodapk.me/

Collapse
 
the_sportsworld_fde05ff3 profile image
The Sports World

To manually sign an APK, first create a keystore using the following command:
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
This will prompt you for passwords and generate the keystore file. Next, sign your APK using jarsigner:
jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore your-app-unsigned.apk my-key-alias
After signing, you can verify the signature with:
jarsigner -verify -verbose -certs your-app-unsigned.apk
Finally, optimize the APK using zipalign (from Android SDK Build Tools):
zipalign -v 4 your-app-unsigned.apk your-app-signed.apk
Now your APK is signed and ready for release. For helpful tools and digital resources, visit: Honista iPhone.

OSZAR »