Android | Running Google Maps API v2 Sample in Emulator


Here is a simple and straight forward Guide on How to Install and Run Google Maps API v2 Sample Code.



STEP ( 1 )
Preparing your Emulator "AVD"

In Order to Run the Sample Code, you will need to have Google Play Services installed in you "AVD", but due to Google Privacy and Security Reasons it is not Allowed to Install Google Play and you will not be able to even add your Google account, here is a workaround to make it happen.

Here i am using a Galaxy Nexux 4.0 AVD
"
1) Create new emulator with next configuration:
www.dropbox.com/s/nunuh9htu25qfpz/stackoverflow_1.png
On other versions I was could not configure because have of various errors when installing the necessary applications.



2) Start emulator and install following applications: GoogleLoginService.apk, GoogleServicesFramework.apk, Phonesky.apk. You can do this with next commands:
2.1 adb shell mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system
2.2 adb shell chmod 777 /system/app
2.3-2.5 adb push Each_of_the_3_apk_files.apk /system/app/
Links to download apk files. (www.dropbox.com/sh/20hcf8kxdk19z3c/Ukc8uGnk7p) I have copied it from my rooted android device.
GoogleLoginService.apk - www.dropbox.com/s/lfde3juixuy88rg/GoogleLoginService.apk
GoogleServicesFramework.apk - www.dropbox.com/s/9kurwyhbbuecaea/GoogleServicesFramework.apk
Phonesky.apk - www.dropbox.com/s/9x8924gtb52ksn6/Phonesky.apk



3) Install on the emulator Google Play services and Google maps. I have an error 491, if installing from Google Play store. I uploaded apps to the emulator and run installation from it(You can use adb to install this). Links to apps:
Google maps - www.dropbox.com/s/koo4wiwqg8agy8n/com.google.android.apps.maps-1.apk
Google Play services - www.dropbox.com/s/bh058hbrelccfsr/com.google.android.gms-2.apk

"

Source : http://stackoverflow.com/questions/13691943/this-app-wont-run-unless-you-update-google-play-services-via-bazaar?s=162d8f18-a9bf-4eca-baed-0bd4f1704614


STEP ( 2 )
Installing the Sample App

Now you can Install the Sample Code Following these Steps:


  1. Select Window > Android SDK Manager and Mark Extras > Google Play Services Then Click Install Packages.
  2. Select File > Import > Android > Existing Android Code Into Workspace and click Next.
  3. Select Browse..., enter <android-sdk-folder>/extras/google/google_play_services/libproject/google-play-services_lib, and click Finish.
  4. Once you have installed Google Play services, you can view the sample code, or run the sample app locally. The sample app is an Eclipse project that you can run on your device as follows:
  5. Select File > Import > Android > Existing Android Code Into Workspace and click Next.
  6. Select Browse..., enter <android-sdk-folder>/extras/google/google_play_services/samples/maps, and click Finish.
  7. Right Click the Project and Select Android Tools > Add Support Library.
  8. Open AndroidMainfest.xml and Add your own Google Maps Android API key.
  9. Select Run > Run to test the sample app.

SNAP SHOT OF APP AFTER RUNNING IN "AVD"






Comments

  1. I have tried your approach but the emulator leads me to the google play website and I am not able to view the map of my application. Has you faced the same problem? Thank you.

    ReplyDelete
  2. go throug the above steps and make sure you select the right version of avd, it is very important to install the *,apk's first...

    i will update the post later with more pictures today .. stay tooned ... (:

    ReplyDelete
  3. Thank you very much for your help Saleh.

    I have followed all your steps, except from the step 2,sub-step 6 because I cannot locate "/extras/google/google_play_services/samples/maps" in my pc.

    ReplyDelete
  4. Hey, I tried installing the apk file via adb command on a windows cmd. But it throws an error as the apk is not signed and cannot be installed. How do I get around this.
    I downloaded the apk's from your dropbox link.

    ReplyDelete
  5. Hey I have tried your approach but I am not able to view the map of my application. I got the system error message. Error message is: Google play service is out of date. I tried a lot to find the solution of that error.

    I tried also another examples of google map at that time only grid is display but not seen the map in my emulator. I got more errors like: 1) "java.io.IOException: Server returned: 3", 2) "at android_maps_conflict_avoidance.com.google.googlenav.map.BaseTileRequest.readResponseData(BaseTileRequest.java:115)", 3) "at android_maps_conflict_avoidance.com.google.googlenav.map.MapService$MapTileRequest.readResponseData(MapService.java:1473)", 4) "at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.processDataRequest(DataRequestDispatcher.java:1117)", 5) "at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.serviceRequests(DataRequestDispatcher.java:994)", 6) "at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher$DispatcherServer.run(DataRequestDispatcher.java:1702)".

    Please give me solutions of this problem as soon as early on my mail id. Email is: sneha2011.jobs@gmail.com

    ReplyDelete
  6. hi there all, i will look into it today and get back to you guys with more details instructions ..

    ReplyDelete
  7. really helpful and working.
    thank you.

    p.s. i suggest to install gmaps e googleservices via command line (adb install..). Trying to install via emulator i get error 903.

    ReplyDelete
  8. Hi, I tried the steps mentioned above. I suppose Google maps did get installed on my emulator. I could see Google Play Services and Maps as installed applications (as shown above). Still when I run the sample apps, I get error: This app won't run without Google Play Services, which are missing from your phone. I see a button "Get Google Play Services". When I click on it, the app stops.

    Please help me.

    ReplyDelete
  9. try downloading this google services apk

    https://www.dropbox.com/s/zm3kscvf269nlcp/Google%20Play%20Services_3.0.25%20%28583950-10%29.apk

    ReplyDelete
  10. Hi man and thanks for your job.

    Just a question: Why we can't install Google Login Service, Phonesky and GoogleServiceFramework with command "adb install"? It fails and throws following error: INSTALL_PARSE_FAILED_NO_CERTIFICATES

    Just wanna learn, i'm a noobie android developer. Thanks again.

    ReplyDelete

Post a Comment

Popular Posts