Generating the SHA1 fingerprint

Let's learn how to generate the SHA1 fingerprint on different platforms one by one.

Windows

The keytool usually comes with the JDK package. We use the keytool to generate the SHA1 fingerprint. Navigate to the bin directory in your default JDK installation location, which is what you've configured in the JAVA_HOME variable, for example, C:\Program Files\Java\jdk 1.7.0_71. Then select, File | Open command prompt.

Now, the command prompt window will open. Enter the following command, and then hit the Enter key:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

You will see an output similar to this:

.............
Valid from: Sun Nov 02 16:49:26 IST 2014 until: Tue Oct 25 16:49:26 IST 2044
Certificate fingerprints:
 MD5: 55:66:D0:61:60:4D:66:B3:69:39:23:DB:84:15:AE:17
 SHA1: C9:44:2E:76:C4:C2:B7:64:79:78:46:FD:9A:83:B7:90:6D:75:94:33
............

Next, note down the SHA1 value, which is required to register our application with the Google Developer Console:

Windows

The preceding screenshot is the typical output screen that is shown when the command is executed.

Linux

We are going to obtain the SHA1 fingerprint from the debug.keystore file, which is present in the .android folder in your home directory. If you want to install Java directly from PPA as given in Chapter 1, Setting Up the Development Environment, open the Terminal and enter the following command:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

This returns an output similar to what we obtained in Windows as shown previously. Note down the SHA1 fingerprint that we will use later.

If you've installed Java manually, you need to run the keytool from the keytool location. You can export the Java JDK path as follows:

export JAVA_HOME={PATH to JDK}

After exporting it, you can run the keytool as follows:

$JAVA_HOME/bin/keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

This command produces the following output:

Linux

Mac OS X

Generating the SHA1 fingerprint on Mac OS X is similar to Linux. Open the Terminal and enter the following command. It will show an output similar to what we've obtained in Linux. Note down the SHA1 fingerprint that we will use later:

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android