Running Google Maps in an AVD

by Jeff Langr

July 03, 2013

After a couple failed attempts, I managed to successfully run com.example.mapdemo in an Android Virtual Device (AVD). It’s not tough, but required cobbling together instructions from a variety of sources.

The following instructions work for the ADT installed under Ubuntu, version linux-x86-20130522. I make no guarantee that these steps will work for you. It’s possible that some of the steps are extraneous.

  1. Using the Android SDK Manager, install Google Play Services (v7).

  2. Using the Android SDK Manager, install Google APIs (v3) (located under Android 4.2.2 (API 17)).

  3. Using the Android Virtual Device Manager, create an AVD with a target of Android 4.2.2 – API Level 17. (I created mine with a 4.65″ 720p, not sure if that’s important.)

  4. Start the AVD

  5. Download two application package files (APKs): and

  6. Install the APKs using adb (located in the ADT directory ./sdk/platform-tools):

        adb install
        adb install
  1. Restart the AVD

  2. Copy ./sdk/extras/google/google_play_services/libproject/google-play-services_lib/ to your Android projects area.

  3. Create a project for Google Play Services (projects needing to use Google Maps will need to depend on this): Import->Android->Existing Android Code Into Workspace. avigate to ./sdk/extras/google/google_play_services/libproject and select google-play-services-lib.

  4. Create a project for the map samples: Import->Android-Existing Android Code Into Workspace. Navigate to ./sdk/extras/google/google_play_services/samples and select the maps directory.

  5. Create a Google Maps API key (note: these steps supposedly will not work for your production deployment):

    1. Copy the SHA1 from your Android Debug keystore. Here’s the instructions I used under Ubuntu to display the contents of the keystore:

      keytool -list -v -keystore ~/.android/debug.keystore

      By default, the password for the keystore is android.

    2. Go to and select API Access from the menu (to the left).

    3. Click the button marked Create new Android Key….

    4. Paste in your SHA1, append a semicolon, then append com.example.mapdemo

    5. Click the Create button.

    6. Copy the API key into the paste buffer (you will use it in the next step).

  6. Configure the map sample project:

    1. From the project’s build path settings, Add External JAR: ./sdk/extras/android/support/v4/android-support-v4.jar

    2. Go to the Order and Export tab, and export android-support-v4.jar

    3. Go to Properties->Android. In the Library section, add the google_play_services_lib project as a dependency. (You will need to open google-play-services_lib if it is not already.)

  7. Edit AndroidManifest.xml to contain your API key: In MainActivityManifest.xml, ensure you have a meta-data element with something like the following:

    Substitute your API key for the android:value attribute. The meta-data element is a direct child of <application>.

  8. Edit AndroidManifest.xml to contain appropriate permissions. For example (don’t forget to substitute your package name):

Run it!

Here are some of the links I used to piece this together:

Google APIs Console
Install Google Play Services SDK
Sample code
Getting the Google Maps Android API
Getting the Google Maps API Key

Please let me know if I missed any steps or if you discovered something else.

Share your comment

Jeff Langr

About the Author

Jeff Langr has been building software for 40 years and writing about it heavily for 20. You can find out more about Jeff, learn from the many helpful articles and books he's written, or read one of his 1000+ combined blog (including Agile in a Flash) and public posts.