To use Google Maps in Android using MapView Control we need Google Maps API Key. To get the key we have to go through the following steps.

  1. Locate debug.keystore file on your system.
  2. Locate keytool.exe file on your system
  3. Generate MD5 fingerprint.
  4. Use that MD5 fingerprint to get the Google Maps API Key

The debug.keystore file can be found at “c:\users\mir nauman tahir\.android\debug.keystore”

Replace “mir nauman tahir” with your current user name.

Path to debug.keystore

Now navigate to keytool.exe file. “c:\program files\java\jdk1.7.0_02\bin\keytool.exe”

Replace the jdk version with the version installed on your system.

Path to keytool.exe

Now execute the following command.

C:\Program Files\Java\jdk1.7.0_02\bin>keytool.exe  -list -alias androiddebugkey -keystore “c:\users\mir nauman tahir\.android\debug.keystore” -storepass android -keypass android

If prompted for a password, try “changeit” or just press enter key to enter an empty password. This command will return SHA1 fingerprint. jdk1.7 or higher will return SHA1 by default. Remember the bold and italic text is the path to the debug.keystore file. You have to provide the path to debug.keystore file on your system. Secondly the path to the debug.keystore file must be enclosed in double quotes.

jdk1.7 Keytool returning SHA1 fingerprint.

We don’t need SHA1. we need MD5 fingerprint so either we have to use jdk1.6 or we can use the following command to generate MD5 finger print using jdk.17.

C:\Program Files\Java\jdk1.7.0_02\bin>keytool.exe -v -list -alias androiddebugkey -keystore “c:\users\mir nauman tahir\.android\debug.keystore” -storepass android -keypass android

By putting a “-v” in the command it will generate the following output.

jdk1.7 keytool generating MD5 fingerprint

Copy the MD5 fingerprint. LogIn to your google account (even signing in to gmail will work). Than navigate to the following url http://code.google.com/android/maps-api-signup.html . Paste your MD5 fingerprint in field shown in the picture below and click generate api key.

Using our MD5 fingerprint to generate the Google Maps API Key

When you click generate button you will be taken to another screen showing your MD5 fingerprint, your Google Maps API Key and how you can use it in your code to enable Google Maps in Android development.

Google API Key generated by using our MD5 fingerprint

Mission Accomplished.

Note:- Please leave your comments if this article was helpful.

If you can’t find debug.keystore file in “.android” folder than follow the link to solve that issue.

http://mirnauman.wordpress.com/2012/04/04/cant-find-debug-keystore-in-android-folder-issue-solved/

About these ads