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.
- Locate debug.keystore file on your system.
- Locate keytool.exe file on your system
- Generate MD5 fingerprint.
- 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.
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.
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.
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.
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.
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.
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.