Update 1.0 of this article at the bottom of the page.

Driving agent for this article

There was some stuff that my readers were eagerly waiting for. With the launch of Android Google Maps API Ver 2.0 everything that was in progress with API Ver 1.0 was a mess. The switching had given a hard time to alot of developers as the way even the sample app is successfully executed is way too complicated. I received tons of emails and requests for support specially for getting the Google Maps API Ver 2.0 key and the part where everything seems fine but map is not displayed. A couple of days back i started working on Google Maps API Ver 2.0. I solved the above two issues and alot more but didn’t posted anything because i was in the middle of successfully executing and displaying the Map. The aim was that I’ll start writing once am done with at lease one successful running application and today i have that running app. During this series of articles i ll take my readers from basic setup and configuration to a successful run of their first Android Google Maps  API Ver 2.0 Application.

Before we start I need my readers to keep this in  mind that they need a physical device to develop and test their API Ver 2.0 Application. I am using HTC One X as my physical device

HTC-One-X

HTC-One-X


What we have and what we need

I believe that we have Eclipse installed,  JRE installed and in place as without JRE Eclipse won’t work and Android SDK downloaded and installed, if not Google has made it easy for us with a single download. Download the ADT Bundle for the following link http://developer.android.com/sdk/index.html . The ADT (Android Developer Tools) Includes Eclipse with ADT PlugIn, Android SDK Tools, Android Platform Tools and the latest Android Image for the emulator. You might need to download the JRE and install it to run the IDE. We need the following to get rolling.

  • Physical Device ( I have an HTC One X)
  • Google Play Services
  • Android Support Library
  • An API Ver 2.0 Key
  • OEM USB Drivers (For windows, as am using Windows 7 Professional 64bit)

In part 1 we will only get all these bits and pieces together so that we can make it work in the later sections bit by bit and piece by piece. Lets say we have the Physical Device so we will move to the next thing in the list i.e, Google Play Services. But before we do that we need to start a new project with the name gmapv2 with Android 4.2.2 and Google API Lever 17. (I hope the reader has some background of basic android development.)

Installing Google Play Services

To get the Google Play Services Launch the SDK Manager from within Eclipse. Click Windows>Android SDK Manager. Scroll down the list and mark Google Play Services.  Click the “Install Packages” button and wait till the installation is completed.

Installing Google Play Services

Installing Google Play Services

When the Installation is done, we will add to our project. The easiest way is Right Click on the project and click on Import>Android>Existing Android Code Into Workspace . Browse to the location of the library project.

Importing Google Play Services

Importing Google Play Services

The location of my library project is

F:\Android\adt-bundle-windows-x86_64-20130219\adt-bundle-windows-x86_64-20130219\sdk\extras\google\google_play_services\libproject\google-play-services_lib

We have to take care when doing this. we have to go to the google-play-services_lib inside libproject that is inside the google-play-services folder. When the import is done successful. Now we have to add a reference to our project.

Reference to Google Play Services

Right click on our project and click on Properties. From the list click on Android. Click Add, browse to the google-play-service_lib.

Reference to Google Play Services

Reference to Google Play Services

Now that we are done with Google Play Services, we will come to Google Support Library.

Android Support Library

To add the Google Support Library , right click on the project and click on Android tools. Than click on Add Support Library.

Adding Android Support Library

Adding Android Support Library

Accept the license agreement and install the support library.

Installing Support Library

Installing Support Library

Save your project and we are done with part 1st of this tutorial. In Part 2 we will learn step by step how we will get Google Maps API Ver 2.0 Key. Getting the API key is the most tricky part.

For Android Google Maps Ver 1.0 developers should click on the following link

http://mirnauman.wordpress.com/2012/01/30/using-google-maps-in-android-development-tutorial-part-1/

Note : Source code for this article

https://docs.google.com/file/d/0B7W5NGdltb1jeXBvRDNqaV9maFk/edit?usp=sharing

Update 1.0 (30th JAN 2014):- Before it was not possible to test an Android Google Maps Api Ver 2.0 on Emulator but now its possible. I ll post both the articles soon . Testing the App on physical device and Testing the App on emulator.

About these ads