What Every Android Developer Should Know About Keystores

If you seriously develop an Android app you will sooner or later get in touch with a Java KeyStore.

You can use the Java keytool to generate a keystore to use in your Android app:

$ keytool -genkey -v -keystore PlanetsDebug.keystore -alias debug -keyalg RSA -keysize 2048 -validity 10000
Enter keystore password:
Re-enter new password:
What is your first and last name?
....
[Storing PlanetsDebug.keystore]

Now you should have a keystore named PlanetsDebug.keystore in the current directory.

As some point you might need the sha1 of the key you just created. (e.g. to use some Google API). You can grab the hash with the following command line:

$ keytool -list -v -keystore PlanetsDebug.keystore | grep SHA1
Enter keystore password:  <ENTER KEYSTORE PASSWORD HERE>
SHA1: AB:CD:EF:12:34:56:78:90:AB:CD:EF:12:34:56:78:90:AB:CD:EF:12

Verify that the generated key has been used for building your application post action with the jarsigner:

$ jarsigner -verify -verbose -certs planets.apk

The default debug keystore used in standard Android builds is located in your home directory: .android/debug.keystore (With a default keystore password android).