Translate

Thursday, November 22, 2012

Generate google map api key


******************************************************************
Author:      Kartik Patel
Date:      2012-11-23
Subject:      Generate google map api key
******************************************************************


Operating Environment:

OS:         Windows 7 - 64 bit
Java:       jdk1.7.0_01, jre7

The debug.keystore contains a digitial certificate that android uses to launch applications on the emulator. The certificate is called 'androiddebugkey'.  We'll need to get some an MD5 hash for this certificate in order register for our map api key.


If you change/update/upgrade android/eclipse then you need to generate new key again in order to make your google map runs perfectly.



Step 1:

Run command prompt as administrator



Step 2:

Go to folder and then into <.android> folder
e.g: C:\Users\xxxxxx\.android>



Step 3:

Write below command on command prompt - It will generate MD5 Hash (Which is required to generate api key):
keytool -list -v -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android
e.g: C:\Users\xxxxxx\.android>keytool -list -v -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android



Result:

As a result you will get MD5 Hash Certificate fingerprint as below:

Alias name: androiddebugkey
Creation date: xxx xx, xxxx
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: xxxxxxxx
Valid from: xxx xxx xx xx:xx:xx xxx xxxx until: xxx xxx xx xx:xx:xx xxx xxxx
Certificate fingerprints:
         MD5:  00:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:00 <=====  We need this
         SHA1: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
         SHA256: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
         Signature algorithm name: SHA256withRSA
         Version: x

Extensions:

#1: ObjectId: x.x.xx.xx Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
xxxx: xx xx xx xx xx xx xx xx   xx xx xx xx xx xx  xx xx  .............Q..
xxxx: xx xx  xx                                        ..db
]
]


#####
Below step 3.1 must not be used in order to generate google map key - I have written below step because i have gone through this and get an error while generate online api key.


Step 3.1:

Write below command on command prompt - It will generate SHA1 Fingerprint (SHA1 is not required to generate API key we need MD5)
keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android
e.g: C:\Users\xxxxxx\.android>keytool -list -alias androiddebugkey -keystore debug.keystore -storepass android -keypass android



Result from 3.1:

As a result you will get SHA1 Certificate fingerprint as below:
androiddebugkey, Oct 30, 2012, PrivateKeyEntry,
Certificate fingerprint (SHA1): xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx



Error from Result 3.1:

The fingerprint you entered is not valid. Please press the Back button on your browser and enter a valid certificate fingerprint.



Reason for Error of 3.1:

SHA1 is not required to generate API key we need MD5.
#####



Step 4:

Now open your browser and go to the following url...
https://developers.google.com/android/maps-api-signup



Step 5:

Follow procedure to a generate api key.
Use only below MD5 Certificate fingerprint to generate api key
00:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:00




Result:

Now you have the api key, you can use it in the layout file of your application.

Your key is:
1xxxxxxx-xxxx-xxxxxxxxxx-xxxxxxxxxxxxx1

This key is good for all apps signed with your certificate whose fingerprint is:
00:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:00

e.g:
Here is an example xml layout to get you started on your way to mapping glory:
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="1xxxxxxx-xxxx-xxxxxxxxxx-xxxxxxxxxxxxx1"
/>





References:

http://www.remwebdevelopment.com/dev/a35/Android-How-To-Set-Up-an-API-Key-for-Google-Maps.html
http://stackoverflow.com/questions/2100158/google-map-not-displayed-in-android
http://stackoverflow.com/questions/3833108/android-google-maps-not-displaying

http://stackoverflow.com/questions/5102219/to-display-the-google-map-on-the-emmulator

No comments:

Post a Comment