How to obtain a Google Maps API Key

90% of mobile apps nowadays incorporate maps.
As a developer, you’ve probably wanted to embed a map into your app. This is arguably the single exercise that has given me the most headache since I started coding on the Android platform.

Anyway, I figured it’s not fair for every budding developer to go through what I did, so I did a simple do-it-yourself tutorial on how to add a map into your app.

You’re welcome:)

I’ve structured them as a series of numbered steps for simplicity.

Here goes:

(it’s important to note that the following steps were implemented on Windows 7; the process is slightly different on Win XP, Linux and Mac. I will might publish a follow up for the latter platforms)

1. Log in as admin.

2. Locate the following files on your file explorer:

a) keytool.exe – This is a little executable file that comes bundled with Java. Normally, you’d find it in your Java installation directory. In my case, it was in: “C:\Program Files\Java\jre6\\bin\keytool.exe”

b) debug.keystore – This on the other hand is the digital certificate used by your IDE to sign your app on completion. On default, it’s located in the .android directory which in my case (could be different on other OS) was in “C:Users\Andrew\\.android\debug.keystore”

3. Open the Command Prompt and enter the following:

“C:…keytool.exe*” -list -alias androiddebugkey -keystore “C:…\debug.keystore*”

-storepass android -keypass android

command to generate md5 key

*Of course, you’ll insert the appropriate paths to locate the aforementioned files.

On successful completion of this step, you’ll be presented with the MD5 certificate fingerprint.

MD5 is some cryptography algorithm. Read more about it on Wikipedia.

4. Armed with your MD5 fingerprint, open your web browser, and navigate to: the Google Maps API sign-up page.

Here, you’ll need to accept the Terms and Conditions. It might be a good idea to read them as well:)

Next, enter the certificate’s fingerprint and click on ‘Generate API Key’

5. Voilà! There goes your API key, a thank you note, and also an example of the layout xml for your map activity (complete with your new API key).

google maps api key

From here, you can now do a whole lot of cool things with maps on your app.

Before you jump in, a few things you might want to take note of:

i. the key generated in the steps above is only valid for the debugging stage of your development process. Once you’re ready to publish the app onto Market, you’ll need to apply for another API key. ( I know, that sucks:( )

ii. remember to add the following to the Android Manifest.xml file:

a) Permission to go online (Google Maps is essentially online): “android.permission.INTERNET” within the ‘uses-permission’ tags

b) Include the Google Maps library: “” within the ‘uses-library’ tags

Note that (a) is a child of the Manifest element, while (b) is a child of the Application element.

iii. the Google Maps library (an add-on within the Google APIs) must be installed into your SDK. This needs to be done manually using the SDK and AVD Manager, accessible from Eclipse.

Happy mapping.

And for the record, the statistic given as the first line on this post is totally made up!
I just figured it would make for a good anecdote:)

2 comments on “How to obtain a Google Maps API Key

Leave a Reply

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

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