How to generate android map api key in windows and ubuntu via command line/tool

In UBUNTU
Step 1 : Open Command prompt

Step 2 : Type the following command keytool -list -keystore < path of .keystore file >

For path of the .keystore in Eclipse IDE Go to Window --> Preferences --> Android --> Build

Here you will find Default debug keystore : field which contains the path of the .keystore file

Eg: C:\Program Files\Java\jre6\bin > keytool -list -keystore C:\Users\home\.android\debug.keystore Press Enter

Step 3 : Now it will ask for password and the prompt message will be as follows

Enter keystore password :

If you are using the Default debug keystore then the password you have to enter is android.If you are using your own custom debug keystore, enter the password which you have entered at the time of creating it.

Step 4 : After entering the password, Press Enter your output should look like this

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

androiddebugkey, 9 Feb, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 5E:DA:50:A7:0C:D8:1E:78:F0:6D:39:35:5A:CD:62:AB

Step 5 : Copy the Certificate fingerprint (MD5) and Generate Map Api Key 
Step 6 : Now you got your map api key

Eg: map api key --> 0pmXvUobtthEaNCGH1DNKzWIOFl3UIcDEQaXDkA

Step 7 : Use this in your MapView to show Google Map inside your application

Note : While generating map api key always make sure that you are using the same .keystore file which you are using to export the application or generate the .apk file. If you using differnet .kesytore files for generating map api key and generating .apk file then Google Map will not be displayed in your application.

 

In WINDOWS

Step 1 : Open Command prompt and Go to the path where jre is installed

Eg: cd C:\Program Files\Java\jre6\bin Press Enter

Step 2 : Type the following command keytool -list -keystore < path of .keystore file >

For path of the .keystore in Eclipse IDE Go to Window --> Preferences --> Android --> Build

Here you will find Default debug keystore : field which contains the path of the .keystore file

Eg: C:\Program Files\Java\jre6\bin > keytool -list -keystore C:\Users\home\.android\debug.keystore

Step 3 : Now it will ask for password and the prompt message will be as follows

Enter keystore password :

If you are using the Default debug keystore then the password you have to enter is android.If you are using your own custom debug keystore, enter the password which you have entered at the time of creating it.

Step 4 : After entering the password, Press Enter your output should look like this

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

androiddebugkey, 9 Feb, 2012, PrivateKeyEntry,
Certificate fingerprint (MD5): 5E:DA:50:A7:0C:D8:1E:78:F0:6D:39:35:5A:CD:62:AB
Step 5 : Copy the Certificate fingerprint (MD5) and Generate Map Api Key
Step 6 : Now you got your map api key

Eg: map api key --> 0pmXvUobtthEaNCGH1DNKzWIOFl3UIcDEQaXDkA

Step 7 : Use this in your MapView to show Google Map inside your application

 


Behavior of your application when using map api key 

 Scenario 1 (Map Api Key is unique for a system)

-->  You have generated map api key in System  A from command line

---> You are using the map api key in a project which is in System B.

---> If you run/install/export the application(which is in System B) in device then

Google Map will be not be displayed in the device 

Reason : MD5 signature will be private and unique to a particular system. So you cannot run/install/export an application from a System B by using a map api key of System A(which is private to System A).

Scenario 2(Map api key depends on the kesytore)

-->  You have generated map api key from command line using android's default debug.keystore

---> You are using the map api key in a project

---> You have exported the project and generated a .apk file using your custom debug keystore instead of android's default debug.keystore

---> If you install the .apk file in any device

Google Map will not be displayed.

Reason : The keystore which you are using while generating map api key should be same as the one which you are using to export your application or generate the .apk file. If you using differnet .kesytore files for generating map api key and generating .apk file then Google Map will not be displayed in that application.

Please be careful and check these scenario's while uploading your application to market/ playstore and also while submitting your application for Testing .

 

Advertisements

Tags: , , ,

About krishjlk

http://www.facebook.com/krishna.kanth.121

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: