Saturday, June 13, 2015

Google Maps Integrating to Android App

Integration of Google map onto an Android Activity involves multiple steps 

1. Include Google Services SDK into the project and include in the dependency list
2. Create API key for the application 
3. Test and verify everything works 

All these steps are detailed neatly in the links in references. 

Below given are some of the hiccups faced while integrating the map. 

The main one was getting the right SHA1 key. The steps to get the SHA key is 

keytool -list -v -keystore andruks.jks

This gets the SHA1 of the keystone. But during the running via debug, it may be different keystone and the SHA could be different. If we run the app, the log will suggest what should be the SHA1 key to be used. 

06-14 00:35:53.546  16860-17073/lcom.mydomain.myapp E/Google Maps Android API Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
06-14 00:35:53.552  16860-17073/com.mydomain.myapp E/Google Maps Android API In the Google Developer Console (https://console.developers.google.com)
    Ensure that the "Google Maps Android API v2" is enabled.
    Ensure that the following Android Key exists:
    API Key: AIzaSyBgURIAyTk3ENONDMXaXAklVgbtbiqN2Qw
    Android Application (;): 3D:B8:EC:FC:4A:19:0F:1A:1B:C5:1F:EA:E5:C0:F2:96:00:36:10:0C;com.mydomain.myapp

This helps one to copy this and add this in the developer console. 

Another hiccup was when added the Android map via the Activity, it added an additional meta data info and in effect, the below was getting duplicated 

<meta-data
   
android:name="com.google.android.geo.API_KEY"
   
android:value="AIzaSyBgURIAyTk3ENONDMXaXAklVgbtbiqN2Qw" />

This caused the Activity to get crashed as and when it was launched. Just removed the duplicate one and it all worked fine. Below is one screenshot




References:
https://developers.google.com/maps/documentation/android/start
https://console.developers.google.com/project/
https://developers.google.com/maps/documentation/android/start#get-key

2 comments: