Displaying Google Maps in the Android Emulator

Google Emulator - Embed Web maps.
This is a quick and dirty way to display Google Maps in Android. Its really not that hard and after learning how to do this you can easily start thinking about how you want to architect your Android App using the different bundles that come with google (Maps are only one of them!!).

Fire up Eclipse / Create your Project

Easily set up your own project here => I am using GANEYMEDE eclipse, which is the international version of the popular Eclipse IDE. If you don’t have the Android SDK you can download it from here and you can download Eclipse from here.Also make sure you have the latest version of Java => download it from here.

Your first step is to create the project within Eclipse (I will not get into how to install Android onto your computer) so refer to the screenshot.
Create your Android Project

GET YOUR MAPS API KEY

With the Android SDK release v1.0, you need to apply for a free Google Maps API key before you can integrate Google Maps into your Android application. Please follow the simple steps below on how to obtain your key. You may also refer to Googles detailed documentation here. You can also refer to Google’s detailed documentation on the process here.

Since you are testing the application on the emulator locate the SDK debug certificate located in the default folder of "C:\Documents and Settings\\Local Settings\Application Data\Android". The filename of the debug keystore is debug.keystore. For deploying to a real Android device, substitute the debug.keystore file with your own keystore file.

To make things simple just add (debug.keystore) to a folder in C:\ (for example, create a folder called "C:\Android").

Using the debug keystore, you need to extract its MD5 fingerprint using the Keytool.exe application included with your JDK installation. This fingerprint is needed to apply for the free Google Maps key. You can usually find the Keytool.exe from the "C:\Program Files\Java\\bin" folder.

Issue the following command to extract the MD5 fingerprint.

keytool.exe -list -alias androiddebugkey -keystore "C:\android\debug.keystore" -storepass android -keypass android

cmd

Modify your android manifest.xml file

The manifest file describes the components of the application — the activities, services, broadcast receivers, and content providers that the application is composed of. It names the classes that implement each of the components and publishes their capabilities (for example, which Intent messages they can handle). These declarations let the Android system know what the components are and under what conditions they can be launched.

Displaying your map

Next to display the Google Maps in your Android application, modify the main.xml file located in the res/layout folder. You shall use the element to display the Google Maps in your activity. In addition, let’s use the element to position the map within the activity:

Make sure that you have applied your android api key

Modify the MapActivity class

Lastly all you need to do is modify the MapActivity class in your #src folder. (Maps.Activity.java)

The above steps are all you need to actually display the maps in your emulatore. Press F11 in Eclipse to deploy the application onto an Android emulator. If you are experiencing problems then look over these three troubleshooting steps below:

Make sure that you add the package in your AndroidManifest.xml file.

Make sure you have internet permission (if you see nothing but grids in the emulator.) in the AndroidManifest.xml File.

11 Comments Displaying Google Maps in the Android Emulator

  1. Frank Bouwens

    ¨The filename of the debug keystore is debug.keystore. For deploying to a real Android device, substitute the debug.keystore file with your own keystore file.¨;

    How do i subsitute the debug.keystore file with my own keystore file?

    Reply
  2. Pingback: My emulator looks different than in the examples! « Android from scratch

  3. Blaine Clankscales

    Hi, I recently bought a HTC Tattoo and I have to say that I love Google Andriod it is by far the best mobile os I have tested. The endless supply of awesome apps makes every day with my phone an adventure.Sorry for my long rant I just wanted to tell you my experience with the android os. Have a great day and thanks for a great blog.

    Reply
    1. admin

      Hey Blaine, thanks for stopping by appreciate your kindness. I don’t have an Android Phone but spent some time programming a couple of simple apps. Really great stuff!!

      Reply
  4. Deandrea Lockerz

    Hey there, Very nice blog i’d like to say immediately. I’ve seen A large amount of posts about lockerz being a scam and i’d simply prefer to say that this seriously isn’t true. I have won a Macbook Pro from there. If you’d want to have an invite for Lockerz then go to Lockerz Invite Only thought i’d let you know :)

    Reply
  5. patrick

    Hi, i’m new to the development of android sdk, i’m facing some problem, when i use the dubug API key, it works , but when i use my own complied API keystore, what i get is only the grey grid, firewall, antivirus, i already switch off, and i tried many times re-assigned the key, and get the new API key, but it still can’t works.

    hope someone here would help me, i’ll appreciate alot . =(
    thanks.

    regards
    patrick

    Reply
  6. ITtuition.com

    Good stuff. People should read this before they read that Google’s manual. Thanks for sharing this. BTW, your xml files (manifest and main layout) rendered invisible in my firefox. Had to open the source of the page to see the content. Maybe it’s because you specified lang=JAVA for them?

    Reply
  7. map not open in emulator

    I am using fir up eclips and set debug key…. in my system has window 7….. but in emulator not open in emulator

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>