Implementing Maps In Android

If you are a developer, it is expected of you to learn new things frequently because techniques and approaches evolve often.

I know this can be pretty much difficult especially if you have an 8 to 5 job where deadlines and the likes won’t help matters.

Enough story :D.

I recently worked on an android project that required me using Maps API. I had idea of how to go about in my head (this is a common thing) but I have never really worked with too many APIs from google play services.

Most of the tutorials I found used Eclipse and I wanted it done in Android Studio (AS).

One of my many challenges was gradle (we all know this feeling). I didnt have an updated version of google play services and gradle no gree. That was solved gallantly.

I successfully had a successful implementation with the help of a colleague and I felt a sharing the knowledge wont do me any harm. Would it? ;).

Step 1:

  • Get your SHA1 certificate fingerprints by typing this (keytool -list -v -keystore “%USERPROFILE%\.android\debug.keystore” -alias androiddebugkey -storepass android -keypass android) on your command prompt. Note your SHA1 key

1

Step 2:

2

3

  • Enable API

4

  • Select Credentials from the left pane and click on CREATE NEW KEY.Then you select Android Key

5

  • Insert your SHA1 certificate fingerprints and package name separated by a semi-colon (e.g 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.example) and generate a new key
  • Yaayy! We have a new API key for our android app. You should have something like this.

6

Step 3:

  • Create a new Activity in your project and select Maps Activity (New>>Google>>Google Maps Activty)
  • At this point, AS should help you pull the needed dependencies. Any luck with gradle? If you have any challenge, mention me on twitter.
  • Replace the key in the google_maps_api.xml with the key that was generated in the console.

71 81

  • Just for a check. Confirm that your AndroidManifest.xml has the following permissions

81

  • Run your project and all these should  have led you to a successful journey on Maps. See my screenshot below.
  • Now all you need do is play around with Location class and fix your longitude and latitude.

8

Advertisements

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s