lunes, 19 de agosto de 2013

HowTo use GoogleMaps API v2 on emulators

(Spanish version here)

Hi all, some months ago I have been exploring the Android programming platform and one of the most interesting faces is the google maps.   With Google Maps API v1 it was relatively easy to use maps in our apps (see http://www.sgoliver.net/?p=1949), however with the API v2 release many developers have found troubles to tests their applications in the platform emulators.

Fortunately, these problems often find their way to solve them thanks to the perseverance of users with the need to move the obstacle, that way I have been looking for the way to make Google Maps API v2 working on the emulators and with some info found in some places I got the way to make it working for me so knowing the needed of many people I want to share the steps that worked to me and hope they can help some one else.

Well, that's it, so let's describe the process:

1. Updates

First of all I had to update  Android SDK Tools  and Android SDK Platform-tools

From Android SDK Manager Update:

Tools:
    Android SDK Tools a 22.0.5
    Android SDK Platform-tools a 18.0.1

Android 4.1.2 (API 16)
    Install SDK Platform
    Samples for SDK (opcional)
    ARM EABI v7a System Image
    Intel x86 Atom System Image
    MIPS System Image
    Google APIs



2. google-play-services_lib library

2.1 Download the google-play-service from the following location (this is which worked to me, before I had installed the one with comes with the SDK but I think it is a newer version and maps doesn't work on it)


Download the google-play-services.zip by clicking on the Download button located in the upper right corner.



2.2 Uncompress google-play-services.zip wherever you want (<google-play-services-download-dir>)

2.3 On eclipse, import the google-play-service project (if it already exists, delete it to install this version)

    a. File - Import - Existing project into workspace
    b. In Select root directory: <google-play-services-download-dir>/libproject/google-play-services_lib
    c. In Projects, mark the project: google-play-services_lib
    d. Mark the checkbox: Copy projects into Workspace
    e. Finish



2.4 In google-play-services_lib project go to Properties - Android:

    a. In Project Build Target mark: Android 4.1.2
    b. In Library check the Is library is marked
    c. Make a clean and build to this recently imported project




3. Actions in the project using the maps

3.1 In the project go to Properties - Android

    a. In Project Build Target mark: Android 4.1.2
    b. In Library add the google-play-services_lib library



3.2 In the same Properties window, go to Java Build Path - Libraries

3.3 Check Android 4.1.2, Android Dependencies y Android Private Libraries are present.



3.4 Click Ok

3.5 In the project contextual menu go to Android Tools - Add Support Library

3.6 Accept the license

4. Emulator setup

4.1 Create a new emulator with the following configuration:

    In Android Virtual Device Manager:

    a. Device: 5.1” WVGA (480 x 800: mdpi)
    b. Target: Android 4.1.2 – API level 16
    c. CPU/ABI: ARM
    d. Leave the rest of properties to default



4.2 Start the emulator.



4.3 Download the following applications (from the  pc or laptop where the development environment is set up):

    a. com.google.android.gms-1.apk (http://uploaded.net/file/bnzl1si4)
    b. com.android.vending-1.apk (http://www.androidfilehost.com/?fid=9390135922294521859)

4.4 Start a terminal and install the applications in the emulator by using these commands (adb command is in <Android-sdk-home>/platform-tools)

    a. adb -e install <path-to>/com.google.android.gms-1.apk
    b. adb -e install <path-to>/com.android.vending-1.apk



4.5 We can see the installation of both applications were success, so now we can see that Google Play Services (com.google.android.gms-1.apk) and Google Play Store (com.android.vending-1.apk) are listed in the emulator  (Settings - Apps)



5. Run the application

5.1 At this point I suppose your project is well configured and have the properly permissions, to have a reference of how to create your Google maps API v2 see http://www.sgoliver.net/blog/?p=3244

5.2 Make a Clean and Build of the project.

5.3 Run your application as Android Application






Links:

No hay comentarios:

Publicar un comentario