Android - How To Set Up an API Key for Google Maps

It took me some time to figure out all the steps to get my Android
apps set up to use Google Maps.  Hopefully this will spare you some
time.  First I'll explain how the process goes when you don't have any problems.  If you're having problems, you can click here to find out about the troubles I ran into when I upgraded from SDK 1.1 to 1.5.

Open a command prompt and navigate to a file called debug.keystore. The location of this file depends on what OS you are using. I use Windows XP and my debug.keystore file is located at C:\Documents and Settings\User\.android.

As a side note, before the Android 1.5 SDK came out, my debug.keystore file was located in a different location (C:\Documents and Settings\HP_Administrator\Local Settings\Application Data\Android). When I later updated to 1.5 I ran into all sorts of problems getting the maps to work.

if you use a Mac or Linux OS, I've discovered that you'll find the debug.keystore file at: ~/.android/.

The debug.keystore contains a digitial certificate that android uses to launch applications on the emulator. The certificate is called 'androiddebugkey'.  We'll need to get some an MD5 hash for this certificate in order register for our map api key.

Hopefully you've located the debug.keystore file, so now we'll use Java's keytool utility to get the MD5.

I use XP so I navigated to the proper directory by opening a command prompt and typing:
cd C:\Documents and Settings\HP_Administrator\.android

Once you've navigated to the proper directory for your os, type this in...
keytool -list -alias androiddebugkey -storepass android -keypass android -key
store debug.keystore

Once you hit the enter key, you'll see something like this (the actual MD5 that we're interested in is the last line):
androiddebugkey, Mar 10, 2009, PrivateKeyEntry,
Certificate fingerprint (MD5): D1:16:4A:BD:73:73:A4:56:9D:CD:9A:44:A2:6C:11:AC

Now open your browser and go to the following url...

Accept the agreement and paste the md5 that the key tool returned to you, in my case it was something like...

Then press "Generate API Key" and you'll be redirected to a page that has your api key.

that you have the api key, you can use it in the main.xml layout file
of your MapTest application. Here's what mine looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""

You'll also have to add some entries to your manifest file, here's what mine looks like...

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <!-- this was the kicker - had to import the library!!! -->
        <uses-library android:name="" />
        <activity android:name=".MapTest"
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
    <!--make sure you add the following permissions to your app!!!-->

Here's what my MapActivity looks like(note that it extends MapActivity, not Activiy)...

package com.remwebdevelopment.maptest;


import android.os.Bundle;

public class MapTest extends MapActivity {

    public void onCreate(Bundle savedInstanceState) {

        //you could get a reference to the map view from the main.xml
        //layout like this...
        //mMapView = (MapView)findViewById(;

    //you must provide an implementation for isRouteDisplayed()
    //when you extend MapActivity...
    protected boolean isRouteDisplayed() {
    return false;

You should see a map of the world when you run it.
Hopefully this will get you up and running.  I have other code samples
that might be helpful, I'll be posting them soon.


If you're having problems, I might be able to help you by sharing my struggle to get the maps working after I updated from the 1.1 SDK to 1.5. Click here for more info.


28 Comments - Average Rating:4.21

This technique did not work for me.. Please
Rating: 1
Date Posted: May 16th, 2015

Remember. You need two API keys. One for your Keystore and another for the android self generated debug keystore.
Rating: 5
Date Posted: April 18th, 2013

hey can plz tell me how to make the application run on a real device plz my map application works fine in emulator but map is not showing on real device
Rating: 5
Date Posted: March 31st, 2013

Easy to read, easy to understand. Thanks
Rating: 5
Date Posted: October 19th, 2012

Thanks a million...very clear explanation of something that I was not used to doing.
Rating: 5
Date Posted: August 22nd, 2012

crisp clear example,saved lots of my time.
Rating: 5
Date Posted: June 11th, 2012

Helped me easily get a key in a few minutes, thanks!
Rating: 5
Date Posted: March 10th, 2012

pls tell me what to do, if
we get the error as keytool not recognized?
Rating: 3
Date Posted: February 17th, 2012