Obtaining Google Map API Key

Posted on Updated on

Google API allows one to integrate map feature in android application. The API contains package known as com.google.maps which allows MapView class to display map in your application. The MapView class is a core class which provides map rendering, downloading map data and caching of data. But inorder to use Google Map one needs to have a valid Map Key. The Map API key is obtained using the certificate that is used to sign the application.

As I have previously described how to create certificate through command line.  Once the certificate has been generated use the following steps to obtain MD5 hash value of the certificate which is used to create Map API key.

1.Open command prompt (winkey+R->Type “cmd”).

2.Type the following command 

     keytool -v -list -alias <alias_name>  -keystore <keystore_name>

3. After executing the command it will prompt for keystore password. Enter password and the certificate fingerprints or simply hash value will be displayed in MD5, SHA1 and SHa256 formats.

4.Copy the MD5 hash value and paste  it in the form field of Map API signup page https://developers.google.com/android/maps-api-signup

5. Click “Generate API key” button in the webpage.

6. On successful key generation the following code will be displayed which contains the Map API key

              <com.google.android.maps.MapView
                 android:layout_width="fill_parent"
                 android:layout_height="fill_parent"
                 android:apiKey="018sE6ZHQ_otQKn4CBrTLgTnkp1ytsp__3kkFPg"
                 />

Please note Google Map API key signup service will accept only MD5 fingerprint. It doesn’t allow SHA1 and SHA256 fingerprints. I would like to mention one thing which I have encountered while generating Map Key. It is shown in the developer website to type the following command to generate the key

keytool -list -alias <alias_name> -keystore <keystore_name>

The following was the output

With JDK 1.7 installed, keytool always gives  SHA1 fingerprint by default, not MD5. But MD5 fingerprint can be obtained by adding “-v” after keytool command.

keytool -v -list -alias <alias_name> -keystore <keystore_name>

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