Android - Google MAP V2 PART 1

Tuesday, 19 February 2013

Download and configure Google Play Services Library in Eclipse

Google Map for Android is now integrated with Google Play Services. So we need to set up Google Play Service Library for developing Google Map application in Android.

Get the API key for Google Maps v2:
Linux : 

For any other OS use this : 

 keytool -list -v -alias androiddebugkey \  
 -keystore <path_to_debug_keystore>debug.keystore \  
 -storepass android -keypass android   

Register with the Google APIs Console :  Google APIs Console 

Select here the Services entry:

Activate the Google Maps Android API v2.

Register your application via its package in this console together with the SHA-1 fingerprint of your signature key.
Click on Create new Android Key..

Add you SHA-1 and your package name in to box like example given in alert box.

Support library : Android support library (android-support-v4.jar ) is added to this project by Eclipse IDE to the directory libs.


 Add Play Services Library in project :  
 Eclipse > import > Android > Existing Android code in to workspace  
 Browse you SDK path like ~/android-sdk-linux/extras/google/google_play_services  
 import that project in to workspace  

EDIT : 28/03/14 : if you have google play services rev 13 and more then use below lines in android manifest file.

   android:value="@integer/google_play_services_version" />  

Create New Android Project and flow below step: 

Add library project in to new Project : Project > properties > android > in library section > Add > google_play_services

now in your manifest file :
 <?xml version="1.0" encoding="utf-8"?>  
 <manifest xmlns:android=""  
   android:versionName="1.0" >  
     android:targetSdkVersion="16" />  
   <uses-permission android:name="android.permission.INTERNET" />  
   <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />  
   <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />  
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />  
   <uses-permission android:name="com.djandroid.mapsv2.permission.MAPS_RECEIVE" />  
   <uses-permission android:name="" />  
     android:required="true" />  
     android:theme="@style/AppTheme" >  
       android:label="@string/app_name" >  
         <action android:name="android.intent.action.MAIN" />  
         <category android:name="android.intent.category.LAUNCHER" />  
       android:value="API_KEY" />  
       android:required="true" />  

you layout file:

<RelativeLayout xmlns:android=""  
   tools:context=".MainActivity" >  
     class="" />  

Main Activity :
 package com.djandroid.mapsv2;  
 import android.os.Bundle;  
 public class MainActivity extends FragmentActivity {  
      protected void onCreate(Bundle arg0) {  
           // TODO Auto-generated method stub  

 You have to test the application on a real device as the emulator is not supported.

Download Full Code of PART-1,2,3,4


Adam Wood said...

This works! I just tested this on a phone running Gingerbread (2.3.5) and it worked perfectly! Thank you very, very much!

gil-nam kim said...

Thank you. Your posts helped me a lot!

Dhaval Sodha Parmar said...

Wel come...!

Dhaval Sodha Parmar said...

Wel Come....!

Jigar Tops said...

how can i run This Application in Android Emulator..

Dhaval Sodha Parmar said...

I was written at end of blog.. "Google map v2 is not run in emularot"

If you want to run then install "google play services" & "GSM services in emularot then its run in emulator.

I dont thik we can do that.. So, is not possibke to run Google map v2 in emulator...

varna korepu said...

am getting white screen with android 4.0.4 device

Dhaval Sodha Parmar said...

your code working in any other device? have you checked this?? if it work in any other android device with < 4.0 OS then replay me here with your code.

or if it not work in every device then check your code once again... do all step again which i have explain in above artical.

nikhil said...

Hi dhaval,

I have created a key, installed google play services and using tat jar file in my app but the moment when i click maps it crashes.
I am using 4.1.2 nexus.

Dhaval Sodha Parmar said...

please check logs... and tell me what type of exception you get??

nikhil said...

but the sample app runs properly in device

Dhaval Sodha Parmar said...

you have't add google Play library in your Project check below links.

Gary Blakely said...

I can't copy your code. Can't get it into the clipboard. Do you have a downloadable working project?

Dhaval Sodha Parmar said...

code is here:

Shweta Kamath said...

i m getting the error "unfortunately googlemap has stopped"

Dhaval Sodha Parmar said...

@shweta kamath: please show me full error logs. or show me your code.

Post a Comment