If you have developed any app that contains Google Maps v1, It’s time to upgrade it to Google Maps V2 as google maps version 1 deprecated officially on December 3rd, 2012 and it won’t work anymore. This article aims to give knowledge about how to implements newer Google Maps into your applications. If you have already worked with V1, implementing V2 is very easy. Refer Google Maps Docs for any topic that is not covered in this tutorial.

Download Code

Before starting a new project, we need to go through some pre required steps. These steps involves importing required library, generating SHA1 fingerprint and configuring maps in google console.

1. Downloading Google Play Services

Google made new Maps V2 API as a part of Google Play Services SDK. So before we start developing maps we need to download google play services from SDK manger. You can open SDK manager either from Eclipse or from android sdk folder.

Open Eclipse ⇒ Windows ⇒ Android SDK Manager and check whether you have already downloaded Google Play Services or not under Extras section. If not select play services and install the package.

Android downloading google play services

2. Importing Google Play Services into Eclipse

After downloading play services we need to import it to Eclipse which will be used as a library for our maps project.

1. In Eclipse goto File ⇒ Import ⇒ Android ⇒ Existing Android Code Into Workspace

2. Click on Browse and select Google Play Services project from your android sdk folder. You can locate play services library project from
android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib

3. Importantly while importing check Copy projects into workspace option as shown in the below image.

android linking google play services library

3. Getting the Google Maps API key

1. Same as in maps v1 we need to generate SHA-1 fingerprint using java keytool. Open your terminal and execute the following command to generate SHA-1 fingerprint.

On Windows

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

On Linux or Mac OS

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

In the output you can see SHA 1 finger print.

android google mapsSHA finger print

2. Now open Google API Console

3. Select Services on left side and turn on Google Maps Android API v2

android google console maps api

4. Now select API Access on left side and on the right side click on Create new Android key…

google console generating api key

5. It will popup a window asking the SHA1 and package name. Enter your SHA 1 and your android project package name separated by semicolon ; and click on create.

google console sha 1 finger print

I have given like below

BE:03:E1:44:39:7B:E8:17:02:9F:7F:B7:98:82:EA:DF:84:D0:FB:6A;info.androidhive.googlemapsv2

And note down the API key which required later in our project.

google console android maps v2 api key

4. Creating new Project

After completing required configuration, It’s time to start our project.

1. In Eclipse create a new project by going to File ⇒ New ⇒ Android Application Project and fill required details. I kept my project name as Google Maps V2 and package name as info.androidhive.info

2. Now we need to use Google Play Services project as a library to use project. So right click on project and select properties. In the properties window on left side select Android. On the right you can see a Add button under library section. Click it and select google play services project which we imported previously.

android google play services library project
android google play services library project
android google play services library project

3. Add the Map Key in the manifest file. Open AndroidManifest.xml file and add the following code before tag. Replace the android:value with your map key which you got from google console.

<!-- Goolge Maps API Key -->
<meta-data
     android:name="com.google.android.maps.v2.API_KEY"
     android:value="AIzaSyBZMlkOv4sj-M5JO9p6wksdax4TEjDVLgo" />

4. Google maps needs following permissions and features.

ACCESS_NETWORK_STATE – To check network state whether data can be downloaded or not
INTERNET – To check internet connection status
WRITE_EXTERNAL_STORAGE – To write to external storage as google maps store map data in external storage
ACCESS_COARSE_LOCATION – To determine user’s location using WiFi and mobile cell data
ACCESS_FINE_LOCATION – To determine user’s location using GPS
OpenGL ES V2 – Required for Google Maps V2

Finally my AndroidManifest.xml file looks like this (Replace the package name with your project package)

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="info.androidhive.googlemapsv2"
    android:versionCode="1"
    android:versionName="1.0" >

    <permission
        android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="info.androidhive.googlemapsv2.permission.MAPS_RECEIVE" />

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

    <!-- Required to show current location -->
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <!-- Required OpenGL ES 2.0. for Maps V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name">
        <activity
            android:name="info.androidhive.googlemapsv2.MainActivity"
            android:label="@string/app_name"
            android:theme="@style/AppBaseTheme">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- Goolge API Key -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBZMlkOv4sj-M5JO9p6wksdax4TEjDVLgo" />
    </application>

</manifest>

5. New google maps are implemented using MapFragments which is a sub class of Fragments class. Open your main activity layout file activity_main.xml file and add following code. I used RelativeLayout as a parent element. You can remove it and use MapFragment directly.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</RelativeLayout>

6. Add the following code in your Main Activity java (MainActivity.java) class.

public class MainActivity extends Activity {

	// Google Map
	private GoogleMap googleMap;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		try {
			// Loading map
			initilizeMap();

		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/**
	 * function to load map. If map is not created it will create it for you
	 * */
	private void initilizeMap() {
		if (googleMap == null) {
			googleMap = ((MapFragment) getFragmentManager().findFragmentById(
					R.id.map)).getMap();

			// check if map is created successfully or not
			if (googleMap == null) {
				Toast.makeText(getApplicationContext(),
						"Sorry! unable to create maps", Toast.LENGTH_SHORT)
						.show();
			}
		}
	}

	@Override
	protected void onResume() {
		super.onResume();
		initilizeMap();
	}

}

Run your project and congratulations if you see a map displaying on your device.

android google maps version 2 v2

Placing a Marker

You can place a marker on the map by using following code.

// latitude and longitude
double latitude = ;
double longitude = ;

// create marker
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps ");

// adding marker
googleMap.addMarker(marker);

android google maps v2 placing a marker

Changing Marker Color

By default map marker color will be RED. Google maps provides some set of predefined colored icons for the marker.

// ROSE color icon
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE));

// GREEN color icon
marker.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN));

android google maps v2 changing marker icon color

Custom Marker Icon

Apart from maps native marker icons, you can use own image to show as a marker. You can load the icon from any kind of supported sources.

fromAsset(String assetName) – Loading from assets folder
fromBitmap (Bitmap image) – Loading bitmap image
fromFile (String path) – Loading from file
fromResource (int resourceId) – Loading from drawable resource

Below I loaded a custom marker icon from drawable folder

// latitude and longitude
double latitude = 17.385044;
double longitude = 78.486671;

// create marker
MarkerOptions marker = new MarkerOptions().position(new LatLng(latitude, longitude)).title("Hello Maps");

// Changing marker icon
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_marker_icon)));

// adding marker
googleMap.addMarker(marker);

Moving Camera to a Location with animation

You may want to move camera to a particular position. Google maps provides set of functions to achieve this.

CameraPosition cameraPosition = new CameraPosition.Builder().target(
				new LatLng(17.385044, 78.486671)).zoom(12).build();

googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

Following are enhancements and features that google maps provides. You can utilize these features which suites to your requirements.

Changing Map Type

Google provides 4 kinds of map types Normal, Hybrid, Satellite and Terrain. You can toggle to any kind of map using googleMap.setMapType() method.

googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
googleMap.setMapType(GoogleMap.MAP_TYPE_NONE);
android google maps v2 changing map type

Showing Current Location

You can show user’s current location on the map by calling setMyLocationEnabled(). Pass true / false to enable or disable this feature

googleMap.setMyLocationEnabled(true); // false to disable

Zooming Buttons

You can call setZoomControlsEnabled() function to get rid of those zooming controls on the map. By disabling these buttons map zooming functionality still work by pinching gesture.

googleMap.getUiSettings().setZoomControlsEnabled(false); // true to enable

Zooming Functionality

You can disable zooming gesture functionality by calling setZoomGesturesEnabled()

googleMap.getUiSettings().setZoomGesturesEnabled(false);

Compass Functionality

Compass can be disabled by calling setCompassEnabled() function

googleMap.getUiSettings().setCompassEnabled(true);

My Location Button

My location button will be used to move map to your current location. This button can be shown / hidden by calling setMyLocationButtonEnabled() function

googleMap.getUiSettings().setMyLocationButtonEnabled(true);

Map Rotate Gesture

My rotate gesture can be enabled or disabled by calling setRotateGesturesEnabled() method

googleMap.getUiSettings().setRotateGesturesEnabled(true);

Although google maps provides lot of other features, I covered only basic topics in this tutorial. Remaining topics seems to be pretty much lengthy, so I’ll post them as separate articles.

Ravi is hardcore Android programmer and Android programming has been his passion since he compiled his first hello-world program. Solving real problems of Android developers through tutorials has always been interesting part for him.
  • Prabodh

    Awesome … Thanks for the Tutorial

    • Thank you bro …

      • kk

        hi my toast is not working while showing current location which i get through latitude and longitude

    • rajan

      hi prabodh you know how to get nearest atm,restaurants from current locatiom

  • Aleksandar

    Can you make a tutorial how to put markers on Google Map from MySQL db?

    • From your mysql db generate a json file containing the information latitude and longitude. On the android fetch and parse the json and using latitude and longitude from json you can display markers.

      Follow below tutorial to know how to generate json from mysql

      http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/

      • Aleksandar

        I tried to do that today, but I am having issue with JSON. Maybe I can send you my code on email, so you can take a look? Tnx

      • aflaouras

        Can you give an example on how to parse the json? It will help a lot!

  • Nijo George P

    How to get Name of Location using google map API?

    • You can’t do that, for that you need to use places api

      • Nijo George P

        is it possible to use it with android? Will you add a tutorial for it here?

  • Awesome

  • yasin dehghan

    method “getFragmentManager” is error
    my android is 2.3.3

    • Try using android.support.v4.jar file in your project.

      • yasin dehghan

        tanx
        update android to api 14 and work
        but map not show
        this msg show “google play services wich some of your app is not suported by your device…”

  • Umang Patel

    Awesome… Very Nice… Thanks for the tutorial..!! 🙂 🙂

  • kalla dalayya

    K thanks ravi i have alredy seen your apps in this.and what is differebce between befor google map v1 and v2 i mean any extra feature than v1.explain me .Thank you

    • Hi Kalla,

      Maps v1 is deprecated and they won’t work anymore. You have to use V2 maps only and implementation of v2 is different from maps v1.

  • Kamran

    thanks a lot Ravi…

  • This is so much easy tutorials with source code ,

    Thanks for your Mehinat (Hardworking) for this valuable resource to new developers.

    send me comlete Android tutorials with source code thanks

    Asad Ali Jogi

    +92-332-2696273

    http://www.fb.com/JogiAsadMirwahi

  • Aguirre

    As always, clear and precise! Thanks for this wonderful tutorial.

    Currently i’m looking for an example of Android Maps 2.0 where using my current location, I can show on the map the positions of place by coordinates coming from Sqlite table within 50meters. Hope you can provide on how to compute list of coordinates within a given radius.

    I’m always folllowing your tutorials. Many thanks!

  • Zuhry Fayesz

    Superb Tutorials Ravi …. Nice and clean ….. very easy to follow. Keep posting new tutorials on android development. Ravi Rockkkssssss !!!!!

  • kalla dalayya

    k it works f9 .then we are implemting musicplayer with equalizer as like poweramp.so you have any source to implement sound quality like poweramp .suggest us with our code samples or links in andoidapi or ndk
    thank you all.

  • Aleksandar Panic

    How to show up a balloon when click on Marker, with let’s say some additional info? Can you please post some code…

  • Jeffy Lazar

    Ravi Tamada …man You are a genius…and a life saver always …
    thanks a lot for every such amazing tutorial …

    • You are welcome 🙂

    • fadil p

      Hi Jeffy.
      I followed Ravi’s android SQLite tutorial,working Google map, working with google places and Maps tutorial, android GPS location Manager,android populating spinner from SQLite database,android dropdown,android alert,android tab layout,android menu and tab tutorials for my MCA main project.
      Thanks once again Ravi.. 🙂

  • Prathap

    Another Great tutorial..

  • Arfan Zarkasi

    Awesome … this is great great tutorial, and help my case… thank you

    i wait for next tutorial around maps v2

  • Arash

    You Are AWESOME Ravi ! I Love your tutorial. please put a tutorial about how can we build an app with sliding activities. like android home or android menu. Thanks alot

  • akas

    googleMap gives the null value ….

  • Ksamasa

    Google-map get white screen on device and emulator

  • ENG

    hi i want your help i run the project on my device s2 and no output the output is white page with zoom and icon in the top and no map loaded help its urgent

  • Guest

    Map is showing blank white screen!!

    • Check whether you generated or replaced the map key correctly.

      • rajan

        you know how to get nearest atm,restaurants from current locatiom

  • hala

    do i need to generatemyown key to run your project on eclipse i want to test the project

    • Yes. As this key is system specific you have to generate your own key.

  • Clyde

    Got It Thanks!

    • hala

      how its still white black forme 🙁

      • Clyde

        my problem was i switched on
        Google Maps API v2 instead of
        Google Maps Android API v2 before on console

        • hala

          and worked for android device ,do i have to generate the key to test his project ,i created aexample and still not worked please i need help urgent
          here is my email

          jhg184@gmail.com

          • Clyde

            Yap generate key for application

            Open cmd

            go to C:Program FilesJavajdk1.6.0_30bin folder

            Execute this command

            keytool -list -v -keystore “%USERPROFILE%.androiddebug.keystore” -alias androiddebugkey -storepass android -keypass android

            And follow the rest of the Procedure

    • hala

      how its still blank page

  • rajan

    thanks

  • rajan

    can anyone tell how to get nearest places from a particular point

  • MD ALI

    GREAT MAN …….RAVI

  • MD ALI

    how to solve google play services which some of your applications rely on is not supported by your device.

  • MD ALI

    how to solve google play services which some of your applications rely on is not supported by your device.(mdadil298@gmail.com)

  • amine

    Thanks sir.

  • Costis

    I get a message:
    “this app won’t run without google play services, which are missing from this phone”
    and the the app still don’t run

    • Guest

      i got this message too, what’s the problem?

      • Costis

        Try the app on a real device

  • Nitin Narale

    Its Very Useful, Thanks Android Hive to support new android developer …

  • Avinash Int

    Great tutorial! nice explanations. very useful information for the android developers. thanks a lot to share.

    ipad application development company in Chennai

  • fadil p

    Hi Ravi,

    Window->Preference->Android->Build shows a MD5 fingerprint and SHA1 finger print.Is this the same finger print getting after executing

    “keytool -list -v -keystore “%USERPROFILE%.androiddebug.keystore” -alias androiddebugkey -storepass android -keypass android”

    • I am not aware of Build Show option. I’ll check and let you know.

      Thank for the new info 🙂

      • fadil p

        Hi Ravi..

        I have tried both the procedure ie,by running the “keytool -list -v -keystore “%USERPROFILE%.androiddebug.keystore” -alias androiddebugkey -storepass android -keypass android” command in terminal and the eclipse procedure(Window-> Preferences-> Android->Build). I got the same SHA-1 finger print for both procedure.
        Please confirm whether the eclipse procedure is dependable or not

  • Pankaj

    Great! having Ravi is like i can never lost within my android code. i am his fan and i’d say from the android music player to his latest tutorial of sqlite . I just love it Thanks for these free stuff. god Bless You mahn

    • Thanks Pankaj for all your support 🙂

      Cheers!

  • lizzyT

    How do I change it from starting with list view with button to show map? I would like to go to the map first zoomed into my location then I have a button to show the list?

  • Guest

    hi ravi i m window8 user.. and when i Run this Code in CMD Prompt “C:Program FilesJavajdk1.7.0_05bin>keytool.exe -list -v -keystore “c:usersravijai.androiddebug.keystore” -alias androiddebugkey -storepass android -keypass android”

    then i got message this message
    access is denided..

    plzzz helpp how get sh1 fingerprint keyy… 🙁

  • ravi chouhan

    hi ravi i m window8 user..
    and when i Run this Code in CMD Prompt “C:Program
    FilesJavajdk1.7.0_05bin>keytool.exe -list -v -keystore
    “c:usersravijai.androiddebug.keystore” -alias androiddebugkey
    -storepass android -keypass android”

    then i got message this message
    access is denided..

    plzzz helpp how get sh1 fingerprint keyy..

  • fadil p

    Hi Ravi, Can you please check this video?

    https://www.youtube.com/watch?v=dSqLKIow7sY

    I think this video will help the people who is facing problem with generating SHA-1 fingerprint using java keytool.

  • fadil p

    Hi Guys here is an easy way to generate SHA-1 finger print.

    ” Ravi, Please confirm whether this procedure is dependable or not ”

    Here is the easy way to generate SHA-1 finger print without executing
    “keytool -list -v -keystore “%USERPROFILE%.androiddebug.keystore” -alias androiddebugkey -storepass android -keypass android”

    Steps:

    1.Open the Eclipse that you are using to develop android apps.

    2. Go to Window-> Preferences

    3.Expand Android(under General)

    4. Click on ‘Build’
    You can see the MD5 fingerprint and SHA-1 Fingerprint .

    I have tried both procedure ie,executed above command in terminal and the eclipse procedure (Window-> Preferences-> Android->Build). I got the same SHA-1 finger print for both procedure.

    • Alokm

      Ultimate Solution or trick thanks

      • fadil p

        Thank you bro ..

  • fadil p

    Hi Ravi Please help me to solve the issue “google play services which some of your applications rely on is not supported by your device”

  • Jithin -mindster

    sorry i get error,

    android.view.InflateException:binary xml file line #11 :Error inflating class fragment

    • Der Ääl

      got the same problem…

      • mohammed

        got the same problem

    • Max

      I got the same problem !
      After 3 hours research I found out this is really common error.
      I try so many solutions but nothing work.
      Anyone has experience with this error! Please help and explain

  • Don Tharaka

    Great tutorial. Took me less than one hour to complete!

  • Miguel

    Hi Ravi, I’m getting an error

    ” Google Play Services, which some of your applications rely on, is not supported on your device. Please contact the manufacturer for assistance.” Shall I test this on a real device? Thank You so Much.

    • jaya

      it will not run on emulator,install the .apk file in your device,it will work fine

  • Ayse Yuce

    I try to display simply google map on android device. I did all of the steps. but when i run the program, it stopped. So I debug and it says source not found at ‘setContentView(R.layout.activity_main);’.. How can I solve?

    • jaya

      clean the project and rebuild it,if u are running the same project it should work fine with it,

  • Neha Gupta

    I am implementing this on a device having api level 8. Instead of MapFragment, I have used SupportMapFragment. But still the map is not being displayed. Only the zoom in/out buttons are visible.

    Please help me out.

    • Aman Arora

      I am also having the same zoom in/out issue

      • Did you generated the map key correctly by giving your project package name ?

        • Aman Arora

          I have resolved it 😛 I actually activated Google Maps API v2 Instead of Google Android Maps API v2. And btw this tutorial is simply awesome, real easy to follow and understand 😀 😀

          • Oh. Good 🙂

          • fadil p

            Hi Ravi, Can you please tell me how to

            activate “Google Android Maps API v2 from Api Access while generating the Api Key”.

          • fadil p

            Hi Aman i am facing the same problem ” only zoom in/out is visible “.can u please explain how did u resolved the problem?

          • MAD

            Activate the Google Android Maps API v2 from Api Access while generating the Api Key

          • fadil p

            Hi MAD, Can you please tell me how to
            activate “Google Android Maps API v2 from Api Access while generating the Api Key”.

          • fadil p

            Hi Aman can u please mention the steps ??

    • fadil p

      Hi Neha. Did u fix this problem?

  • Mar Wen

    i got this message: “this app won’t run unless you update google play services” what’s wrong?

    • Mar Wen

      i followed all steps

  • sumaiya fazal

    nice tutorial…

    I found an error on this line …

    googleMap.addMarker(Marker);

    ERROR: syntax error on token “Marker”, VariableDeclaratorId after this token..
    so kindly help me out to solve this problem.. Thanks..

  • Ikhsan

    Hi Ravi.

    I have generate my own key and put in to manifest.

    Then debug your sample on my phone.

    But I still get map doesn’t show up

  • searayman

    Can you please do another tutorial for this but with android studio? I know a lot of people on the internet are having troubles setting this up in android studio.

  • Mounica

    i am getting like ” The app wont run unless you update google play services and dispaying a button update”. even if i am clicking the button nothing is happening..
    i have tried it with different emulators but the o/p is same…
    plz help me..

    • Amit Chandra

      The mapsV2 will run only run on the real device. you have to take your .apk file(in bin folder) and have to install it into your phone and then it will run.

  • Anoop Sharma

    Hats off Sir ..

  • Deaw Nibbāna

    Hi Evrybody,
    I try to install this app same as your instruction on my really mobile but It didn’t to show anything
    Please advise me , sorry I wonder my english to bad.

    Thanks a lot.

    • george Mathew

      1.Make sure you use the key generated by you
      2.Make sure the package name given is correct
      3.The manifest file has other permissions to be included,do refer the same as shown here.This being your project, make sure you just don’t blindly copy paste everything.Make changes for the variables as per your project and run the app.Also hope you are running the same on a device and not on the emulator as google map V2 is not supported on the emulator
      Good luck 🙂

  • manikandan

    this information is not clear ,,…..make it clear

  • Ashok kumar

    Thanks a lot….it is very very useful blog for beginners.

  • tushar pandey

    You are the man …… thanks ravi !

  • Thernat

    Great like always.

  • ravi sharma

    how can find the current Longitude,latitude

  • Mark Jhonson

    How to draw a sea route b/w two ports on map in andorid

  • Pari

    Hi, Ravi, When I run the app, I just see a white screen with a target on top, even if I run your project. what’s the problem?

    • Did you replaced the map key with yours ?

      • Pari

        yes, I did

    • Costis

      The same problem here. White screen and only the zoom buttons are on. It used to see the map but now, nope!!!!

  • Ulisses

    Help me! Error

    Google Maps Android API v2 only supports devices with OpenGL ES 2.0 and above.

    how to Solve

  • Rupesh

    I got null pointer exception initially near the

    googleMap = ((MapFragment) getFragmentManager().findFragmentById(

    R.id.map)).getMap();

    I replaced the MapFragment with SupportFragment which solved my problem.

    SupportMapFragment mapFrag = (SupportMapFragment) getSupportFragmentManager()
    .findFragmentById(R.id.map);

    map = mapFrag.getMap();

    Just posting cause some others may face the same problem. Other than that the code worked just fine for me thanks..

  • Shrinivas Pai

    I am getting an error as no source or JavaDoc can be found at MapFragment, why so ? Please help me

  • varad

    thnx bro

  • Hassan Alsudani

    Amazing .. Thanks a lot.
    Can you explain more how to load an image as marker ???

    steps please

  • Ela

    “the method getFragmentManager() is not defined for the type MainActivity” can you help me?

  • Hasnain Rizvi

    Hey Kindly reply on my comment actually i made an custom info window and that info window implemented on ten marker info window also contains a button but button is just only working on last marker info window kindly if you have a solution reply me thanx

  • Shay

    Hi. Thank you for the tutorial. It actually helps me a lot but I’m facing a problem while running the code. I’m using my Samsung Note 2 to run the code. However, after I run the application, it popups a message “Unfortunately, GoogleMapsV2 has stopped.” At first, I thought my phone was the one which having problem. Then I tried using my friend’s Samsung S3. Same problem happened. One of my friend followed this tutorial just like what I did, he did managed to run the code. He’s using another brand of smartphone. My question is, is Samsung device not compatible to run Google Maps V2 (precisely this tutorial) ?

    • It is not the problem with the device. Connect the device to pc using USB and debug the project in Eclipse. See if you are getting any error in Logcat.

  • mitsus

    Hi,

    i’m try to insert into my preoject, but it don’t work. I’m not able to start not even the sample. I’ve follow all tutorial…imports, ecc, but i’ve this error:

    java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable

    I followed the tutorial exactly! where am I wrong?
    Regards

  • Hari Haran Ayyappan

    Hi ravi , the code which u have wrote is for high end versions, if it needs to support from 2.2 that is api level 8 , then use this code

    GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
    googleMap = ((SupportMapFragment) getSupportFragmentManager()
    .findFragmentById(R.id.map)).getMap();

    instead of

    googleMap = ((MapFragment) getFragmentManager().findFragmentById(

    R.id.map)).getMap();

    in layout

    instead of

    • fadil p

      Hi Hari Haran,Can u please share your Main activity class here?
      Thanks

  • Avinash

    Hi Ravi,

    I am following this tutorial and felt very good to follow. While running the App am getting the following error, please help me out:

    Unable to start activity ComponentInfo{com.android.googlemapview/com.android.googlemapview.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

    TIA.

  • Vinod Chaudhary

    thanx a lot ……nice tutorial….but i want to know is their any way to draw circle on Google map by dragging user finger on map ……please help me

  • motty

    hi ravi, a very nice tutorial, i have a problem, i did everything and stil i’m getting a blank white screen for a few second and then the App is stopped, in the LogCat the first message is: “FATAL EXCEPTION: main” do you have any clue? thanks.

    • Please give complete error report.

      • motty

        hi Ravi and thanks for your quik response, i manage to run the application. after digging deep into the logCat i fond out that i was missing a meta data label in the activity mnifest (shown below) after puting this label everything worked perfect. thanks again and great tutorial.

        • Akane

          I have the same problem, but I don’t know what to do….

          did you do it this way?
          I dispair soon! 🙁

  • ANdroid FReak

    Thanks a lot….your tutorials are simple and clear..It has been a life saver for me many times..

    When i executed this code i got an exception saying…..”Binary xml line…Error inflating class fragment”.However i resolved it when i added
    inside the application tag of manifest…

  • Cool Android Man

    Thanks a lot for this wonderful tutorial……!!!! You are awesome…!!!

  • Akane

    First thanks a lot for the perfect tutorial!
    I hav a problem and need help…
    Here’s the error:

    The meta-data tag in your app’s AndroidManifest.xml does not have the right value. Expected 4030500 but found 0. You must have the following declaration within the element:

    But I have in the meta-data:

    I have no idea anymore, what I have to do….and what I have to enter in the new meta-data?

    Thanks for the help 🙂

    • Cool Android Man

      Hi Akane….actualy we need two meta-data tags…..one is with the API key and the other is what you have mentioned here i.e …..both must be inside the application tag

      • Akane

        and is everything I need to write in? because in an other post on another side they said that I write in the android:value =”4030500″.
        And the way, that both are in the application tag doesn’t change anything….still the same error….

        • Cool Android Man

          yes its all you need to write in….no need of 4030500…..also dont forget the api key metadata tag…i had the same error yestday and i fixed it this way

          • Akane

            Does it matter if I make my api key metadata before the other or does the sequence don’t matter?

          • Cool Android Man

            Why dont you check it for yourself.This is not a place for childish questions.

  • Achyut

    There is a shortcut to get the SHA1 fingerprint……open eclipse…..Take Window>preferences>android>build……..You will get both ShA1 and MD5

    • rahula

      thanks for the great shortcut man…

    • Deepak Kanyan

      what prpse of MD5 key

  • Trizio

    Hi,
    I have an android application that display map.
    It works in debug but when I export e signed version I could not see the map but only the grid.

    I have created into the google consolle a key based on the SHA1 from my file keystore file “keystore.proguard” .
    This file is in the project directory.
    I have used the command: keytool -list -v -keystore keystore.proguard and I have copied the SHA1 code with the “;app-name” that I have taken from manifest package=”com.dune. …

    I have copied back the key android:value=”AIzaSyB3v… inside the manifest file.
    It still works in debug but not in the release version.

    Could I let the file keystore.proguard inside the application directory instead of in the .android?
    Any suggestion?.

    Thanks for the help

  • Asif Sarwar

    Thanks…Mwaah,,,u r my daddy…..:)

  • Afrizal

    Thanks hive…… i can show my map v2…..
    if problems in error-inflating-class-fragment there is one way to resolve it… is in the manifest… please put this…

    it will be resolve your problem….

    for android 8 etc please change mapfragment to support fragment and change ther extends activity to fragmentActivity

    enjoy that….. thanks very much

  • denny

    Hai vi , thanks before with the tutor but why i can’t find any library while when adding library to the project??

  • denny

    Vi now i can find the library , but when i start to build the project it says “Could not locate ‘C:/Users/denny/Desktop/tesgpsmap/google-play-services_lib/bin/google-play-services_lib.jar’. This will not be added to the package.”
    thanks before vi

  • lenaoquica

    Thnk u man! your tutorial was amazing!

  • zargin

    Thank you so much! This tutorial really helps me, since I’m truly a beginner, and this tutorial really tells us step-by-step 🙂 Again, thank you so much!

  • needhelp

    It is VERRY annoying that you can’t test map apps on an android emulator is there really no way around ? it’s a loss of time to configure your device to allow installation of non market apps and having to downlooad them each time you changed them is well annoying ?????????

    • needhelp

      Problem solved maps app running fine in an emulator. I love it when a plan comes together !! .

      • أحمد صوالحة

        Can I Know how Please! when running on emulator it asks me for opengl es v2.. Need help please.

        • needhelp

          opengl is required and must be declared in your AndroidManifest.xml file.I’m willing to tell you how i got a maps app running in an emulator but you need to download several things and i can’t post links here if i do that my post goes to the moderation que.

  • asghar

    Thank you so much for this step by step tutorials . but I have a problem to download package from SDK , because I live in iran an can not access to google service 🙁 . Is there any other way to install Google Play Services to my develop environment , I use ADT to deploy my app
    tnx
    asghar

    • needhelp

      Nope the only reliable way to download that is through the android sdk manager.

      • asghar

        but if i download google-play-service folder container then copy to extra folder inside SDK folder, this work fine .

        • needhelp

          It might work yes but how do you know you have the latest version then ?

  • asghar

    again tnx for your usefull tutorial. i have a question that how can use google map service in API 8

  • tejaswi parande

    Hi, I am trying to run this sample code and I am getting blank white screen. Can you tell me why.

    • needhelp

      Hello,

      Do you get any errormessage ?.If you are trying while using a wifi connection then make sure this line is in your AndroidManifest.xml file

      android.permission.ACCESS_WIFI_STATE (add it if not there)

      uses-permission android:name=”android.permission.ACCESS_WIFI_STATE”

      you need ( at the end but can’t seem to type them here hmmm

      It’s also possible you have misconfiguerd the google maps api (eg wrong apikey or wrong certificate signature)

      • tejaswi parande

        I am not able to find the error. Can you please take a look at my manifest file

        • Kamalkjs

          it means your application Id is not correct that is why you are getting Blank Screen.

  • Nor Alia Zulaika Mohamed

    my coding have problem when “googleMap” and “Bundle” cannot be resolved type…what is mean??

    • needhelp

      Hello,

      for googleMap check if you linked the google play library correctly to the project (see above for instructions) also make sure the correct imports are in your source code eg

      import com.google.android.gms.GoogleMap;

      Also note java is case sensitive googleMap is not the same then GoogleMap if you are using Eclipse point your cusor over the error and it will try to help you solve the error(s)

      for Bundle make sure import android.os.Bundle; is there

  • vib

    Run on mobile device run properly but not show the location on the map……..plz help me….

  • Sam

    Thanks for all the tutorials on AndroidHive they are wonderful :), but in this i have problem, I’m getting ANR on my emulator when i run the app… Pliz help.. Here is what LogCat is showing is the cause {Caused by: android.View.InflateException: Binary XML file line #6: Error inflating class fragment }

    • Hi Sam, Google Maps V2 won’t run on Emulator. (This error is not related to emulator anyway)

      • Ahmad

        I’m sorry for disturbing you , it’s not related to that post but I don’t know where to find a solution

        Please could you help me with play mutiple songs from res/raw folder? I really need it if you have time .. thanks in advance
        man 🙂

        http://www.androidhive.info/2012/03/android-building-audio-player-tutorial/

      • Patra Jasa

        hi ravi, i got same error with sam, and i have searching the way to solve the problem, the tutorial say, to change Activity to be FragmentActivity, when i change it, i still get same error, can u help me how to solve it?

      • Christ Samuel

        12-23 09:11:06.156: E/AndroidRuntime(24054):
        FATAL EXCEPTION: main
        12-23 09:11:06.156: E/AndroidRuntime(24054):
        java.lang.RuntimeException: Unable to start activity
        ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}:
        android.view.InflateException: Binary XML file line #8: Error inflating class fragment

        I import the code from above, and i got this error.
        What’s this ?? What should i do to solve this problem ??

        • Nijo George P

          12-27 15:27:32.823: E/AndroidRuntime(4590): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googlemap.location/com.googlemap.location.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

          i’m getting the same error while running. Can anyone tell me about some working solutions?

          • needhelp

            In your map layout xml make sure this line is there

            class=com.google.android.gms.maps.MapFragment

      • sunil sunny

        Hai,
        I am using a real device ,ie sony xperia sl (4.1.2).
        still i am getting the same error as Sam..
        Any suggestions..

  • dremmerd dremmy

    I had a problems with this line

    vate void initilizeMap() {
    if (googleMap == null) {
    googleMap = ((MapFragment) getFragmentManager().findFragmentById(
    R.id.normal)).getMap();

    the error said “Multiple Marker at this line
    -MapFragment cannot be resolved to a type”

    how can i fix this? / Thank you

    • needhelp

      import com.google.android.gms.maps.MapFragment;

      is that line in your code ?.Did you correctly link the google play services library to your project ?.The null check is there to avoid a NullPointerException.

      • dremmerd dremmy

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_item); —> in eclipse said i need to change this

        try {
        // Loading map
        initilizeMap();

        } catch (Exception e) {
        e.printStackTrace();
        }

        }

        /**
        * function to load map. If map is not created it will create it for you
        * */
        private void initilizeMap() {
        if (googleMap == null) {
        googleMap = ((MapFragment) getFragmentManager().findFragmentById(
        R.id.normal)).getMap(); —–> i had problems with this line again

        First time it asked me to remove the android.R to keep activity_main
        but when i removed it, there are still problem in R.id.normal and around mapfragment again.

        • romy

          how we open a particular country map in android for example i would find to in india state delhi how can i open it map

        • abinash

          how to do jumping the pin in a google map application

    • SickLickWill

      I had the same issue, you just need to import the MapFragment class.

      Add this line to the top of your code:

      import com.google.android.gms.maps.MapFragment;

  • Costis

    I get the messages:

    “The Google play services resources were not found. Check your project configuration to ensure that the resources are included” (I have include the resources!!!!!!!)

    “Authorization failure. Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.”

    I follow all the steps but …nope!!!!!

    • Kim Youngsic

      Check your Eclipse : Window > Preferences > Android > Build, Maybe you can see two SHA1. You have to use Custom debug key store SHA1

  • Sulbi

    Add this in manifest if any probs arise..!!

    • Patra Jasa

      how to get @integer/google_play_services_version, or its same like API key

  • hitaf

    hi, thank u for this great tutorial.
    I upgraded the code with some geographical coordinates and some Toast objects to see if there is any exceptions/problems. The app starts without any problems on my phone but I see only a white background with google-label, compass and zoom symbols etc. Have you any idea where the problem is?

    • needhelp

      Most likely your AndroidManifest.xml is missing a needed permission or your maptype is set to GoogleMap.MAP_TYPE_NONE remember that if your device is using a wifi connection you need the wifi related permissions to.

      • Zukisani Zamela

        Hi. I am getting the same problem as him:

        1: Not using wifi.
        2: GoogleMap Type is not NONE. In fact I have tried all of the different types.
        3: I think I have added all of the permissions needed:

        I have been at it since yesterday. I don’t know what’s wrong.

      • Branislav Ballon

        This helped me:

        1. uninstall app from phone
        2. restart phone
        3. restart eclipse

  • Panda

    Hi nice tutorial, but I have a problem in my project , I have this error :
    unable to resume activity nullpointer googlemaps android

    I don’t see any errors or red exclamations .. 🙂

    • Guest

      Now I have this error : Call requires API level 11 (current min is 8): android.app.Activity#getFragmentManager on the code : getFragmentManager().findFragmentById(

      • needhelp

        This is normal because the Fragment class requires api level 11 or up you cannot run fragments on older android versions unless you use the android support library.Open AndroidManifest.xml and change minSdkVersion=11 .

  • Ado

    hi i have error in main_activity googleMap = ((MapFragment) getFragmentManager().findFragmentById(

    • Aseem Sharma

      Import these in your class:

      import com.google.android.gms.maps.MapFragment;
      import com.google.android.gms.maps.GoogleMap;

  • Anthony Pearce

    Let me start by saying I’m a NOOB at this. I have a number of error messages:
    1. In AndroidManifest.xml I have the following Warning:
    Not targeting the latest versions of Android… android:minSdkVersion=”8″. I changed this to 11 but no luck.
    2. In MainActivity.java I have the following errors:
    MapFragment cannot be resolved to a type
    GoogleMap cannot be resolved to a type
    Toast cannot be resolved
    Toast cannot be resolved to a variable

    Does anyone have time to help me sort this?

    • needhelp

      Hi Anthony,

      1) this is a warning that you are not targeting the latest SDK apilevel you have installed.Since your configuration can differ from mine i can’t tell you what to put there but that number should be latest SDK apilevel (you have installed though the sdkmanager)

      2)This is a warning because you are trying to use the MapFragment and GoogleMap classes but whatever envirement you are using can’t find them.You have to add an import statement

      import com.google.android.gms.maps.MapFragment;
      import com.google.android.gms.maps.GoogleMap;

      if after adding these lines you still get the error then you did not add the playservices library to your project (explained above)

      This is needed for Toast

      import android.widget.Toast;

      If you are using Eclipse point your cusor over the code that is causing a problem it will try to help.

      • Anthony Pearce

        Thank you. Your suggestions fixed my problems. All I needed was to add 2 lines that you provided. There are now 0 errors or warnings. However, apparently I don’t know how to run the project.

        • Anthony Pearce

          OK I have redone everything. I have 0 warnings and 0 errors showing. I do not,
          however, know how to run it in eclipse. I would also like to export it somehow to my phone to test it in action. Any help on this please?

          I have a Motorola Atrix HD, OS 4.1.1. I can’t find that option, but not even sure if I’m trying to run it correctly anyway.

          • needhelp

            Hi Anthony,

            Normally you can run an app within an avd(android virtual device) but a maps app cannot do this because the required stuff is not available on a emulator

            Inside the folder where your project is stored you will find a subfolder called “bin” and there you will find a file “appname.apk” (if you successfully compiled) now upload that file to an ftp somewhere you have access to and after that configure your phone this is needed because android is secured against the install of non market apps you need to enable “unknown sources” in the security settings of your phone (this will allow installation of your app) now open a webbrowser download your apk and install and watch it in action

            homescreen =>settings => more => security check “unknown sources” (disable this after your done)

          • Anthony Pearce

            Perhaps I’ve missed a step then because I find no .apk file in bin. I followed your instructions, and found nothing referring to a compilation step. Perhaps I’ve overlooked it.

          • needhelp

            Anthony,

            There are 2 kind of programming languages interpreted languages and compiled languages.

            Perl,Python,PHP are examples of interpreted languages
            Java,C++,Delphi are examples of compiled languages.

            Compiling means that the code the programmer creates is converted to machine language.

            In Elipse check the project and see if there is a checkmark before “build automatically” (in the project menu) if that checkmark is not there either check it or choose build project.

          • Anthony Pearce

            Build Automatically is checked, Build Project is gray which makes me assume it has already been built. There is not, however, a “.apk” file in the bin folder.

          • needhelp

            Strange ….. ok try to run your app in an emulator it will fail i already can tell you that but it should create the apk

            1)create an avd (android virtual device) with avdmanager.exe in your sdkinstall folder.

            2)head over to Elipse and click the run menu select “run configurations”

            3)If there is already a run configuration for your product select it if not create one

            4)select the target tab and select the avd you created in step one click apply after it close this dialog do not click run

            5)right click your project and choose “run as” => android applicatioin

            do not click the button that is displayed about google play services are missing it won’t do anything

            now while the emulator is still running check the bin folder.

          • Anthony Pearce

            For the firs time, there is now an apk file. I don’t have access to an ftp though, so how else could I get it to my phone?

          • needhelp

            with Bluetooth if both your computer and your phone have support for it or by attaching your phone with a usb cable to your computer and put the apk on your memorycard if you have one.

            Remember to configure your phone to allow non market app installs ….

          • Anthony Pearce

            I appreciate your help, but am getting quite discouraged about this whole ordeal. I seem to be having problem after problem, and don’t want to be wasting your time.

            I cannot seem to get the bluetooth connection between the laptop and phone, so have connected the usb. I can’t seem to copy/paste the .apk file, so have explored other methods.

            Right Click – Export – Android – Export Android Application

            Project Checks – Next – Asks for keystore Location:

            I selected “Use existing keystore” and gave the path to debug.keystore
            (I believe this is the correct location.

            I know nothing of a password to use but cannot click “Finish” without one.

          • needhelp

            Well it’s normal you get discouraged but in your first post here you said you are a newbie at programming well the problems you dealed with so far are exactely that newbieproblems and that’s nothing to be worried about everybody whas new to programming stuff including me

            Using the export wizard won’t help you that is used when you are ready to publish your app to the Google Play Store it all android apps must be signed or Google will refuse them they also cannot be signed (for distribution) with the certificate the ADT (Android Developer Tools) generates

            Doesn’t your internet provider offer some free webspace ? you could also try attaching the phone to your computer and install with adb from the developers tools.

            Also you didn’t quite choose the easiest thing to start with Google maps is quite complex

          • Anthony Pearce

            Well it’s on the phone now, but when I click the icon it gives me the message “Unfortunately, Gotta Go has stopped. Gotta Go is my app name.

          • needhelp

            That means there is an Exception somewhere when you run that app with a emulator what does logcat say ? logcat is a view at the bottom of Eclipse exceptions will show up there

          • Anthony Pearce

            If this is something I could have accidentally closed, then perhaps I have. I don’t find a logcat, or exceptions.

          • needhelp

            You can get it back via window => show view =>other=> android select logcat and run with a emulator also did you correctly generated a apikey ? are your permissions set in AndroidManifest.xml all these things can cause exceptions .

          • Anthony Pearce

            OK logcat is open and I don’t see anything obvious there, as in nothing is listed. As far as the api key, I’m not 100% certain. I followed your instructions in the command prompt, and got the message
            ‘keytool’ is not recognized as an internal or external command, operable program or batch file.
            Perhaps I was performing this at the wrong level, but I can’t be certain. But I did find a text document where I had saved a previous api key that was activated on October 22, 2013 so have used that key. It says it is a key for browser apps. Could that be the problem?

          • needhelp

            The message about keytool means the jdk (Java Development Kit) bin folder is not in your PATH system variable and yes that key will not work because Google map apps require both your packagename and the SHA1 hash of your signature at the the top of your java sourcefile there is a statement

            btw do you even have the jdk installed ?

            package com.whatever.here;

            apikeys are uniquely generated for that package you can change that in Google api console. (Google this if you don’t remember where it is) can’t post links or the system thinks i”m a spammer haha

          • Anthony Pearce

            I appreciate all your help, but this is turning out to be quite publicly humiliating for me. Is there a way to communicate privately with you, perhaps through facebook or skype?

          • needhelp

            I don’t use facebook nor skype

          • Anthony Pearce

            how about email?

          • needhelp

            allright use this rscalover(@) gmail(dot)com offcource leave out the () and dot well you know what a dot is that is just to confuse spambots.

          • Anthony Pearce

            Thank you. I have sent you a message. codenoob is my gmail id.

    • Guest

      Hey there is no big problem in this . All you need to do is import the related android classes into your class. Just take your mouse over the error and it will hint you to import the related class.

  • Kishan Pawar

    Hi Ravi, When I run the project. On the Emulator I get this message instead of Displaying maps.
    What should I do? Plz Need help..

    Message is:
    Google Play services, which some of your applications rely on, is not supported by your device. Please contact the manufacturer for assistance.

    • Aseem Sharma

      hello Kishan,
      Google maps cannot be displayed in emulator, for this you have to use a real device. And make APK with the keystore which you used to add SHA and package name to generate the map key as shown in above tutorial. Then you will find map.

      • sunil sunny

        Hai,
        I am using a real device ,ie sony xperia sl (4.1.2).
        still i am getting the same error as Nijo george..
        Any suggestions..

        • Aseem Sharma

          hello,
          I need to ask you that are you running your app directly, because you need to export it first as a signed application(Right click on project > Android tools> export as signed application) with the same keystore, of which(SHA1) you have used for generating android key(for map) in google developer console. I prefer keep a separate keystore or rather generate a new one for running this your sample app.
          Hope this might help you.

          • Shinu

            HI
            I followed the same procedure . still I am getting “Unfortunately GoogleMapApp has stopped”

  • Nijo George P

    12-27 15:27:32.823: E/AndroidRuntime(4590): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.googlemap.location/com.googlemap.location.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    How can i resolve this issue?

  • Jefrey Piekny

    Nice tutorial:) How can show markers in specific zoom, Can you show example?

  • Naun

    Love you man!

  • sachin thawari

    Hi Dear…and thanks for nice tutorial!!!1
    I want to search any location on map by entering name of place in text find find respective place.what is the process for same please give some easy demo example ….thanks

  • Kocis

    Hi, great tutorial.

    I’ ve a simple error, while i’m exporting the project, that I don’t understand.

    “app_name” is not translated in af, am, ar, be, bg, ca, cs, da, de, el, en-rGB, en-rIN, es, es-rUS, et, et-rEE, fa, fi, fr, fr-rCA, hi, hr, hu, hy-

    rAM, in, it, iw, ja, ka-rGE, km-rKH, ko, lo-rLA, lt, lv, mn-rMN, ms, ms-rMY, nb, nl, pl, pt, pt-rBR, pt-rPT, ro, ru, sk, sl, sr, sv, sw, th, tl,

    tr, uk, vi, zh-rCN, zh-rHK, zh-rTW, zu

    i see that in google library there’s translation in all the languages, but how I could fix this error???

    thanks in advance!!

    • Candra Adi Putra

      delete those folder …

    • Rajiv

      Unchecked two options in eclipse “Windows->Prefrences->Android->Lint Error Checking”.

  • Vallabh Lakade

    i am getting an error Google play services not up to date even though i have got all the updates installed

  • Shivaprakash Patil

    I already install google play service in my android sdk.
    when I run the google map application on emulator, it always shows me “This app won’t work unless you update Google play service “. I follow the same procedure as you mention above. But still getting same problem. Please suggest me how to resolve this problem

    • Candra Adi Putra

      try in real device…..

      • Shivaprakash Patil

        Yes. It is working with real device. Thank’s Candra. But for testing every time is not possible to test it on real device. Is there any possible to test it on emulator.

  • fadil p

    Hi Ravi, How to switch the map mode from application? ie,from normal to satellite ?

  • JY

    hi my name is JY

    i appreciate. you have provided this code

    but my device have been being stopped after running this code.

    i don’t know cause so i have written this article

    i want to your help

  • Srinidhi Shankar Habbu

    i copied the exact code that is given here into my application.Made the necessary changes(like API key) and tried running it on my device.But the application is force closing itself without even opening. Infact i imported the exact source code into eclipse and tried running it.The app forced closed itself. But when i installed the apk directy from the bin folder it worked.what am i doing wrong?Any suggestions would really help me..Thank you..

    • Lindon Lee Maquidato

      I’m also experiencing that case.

      • JJ

        me too

        • Leonardo Lopes

          me too

          • luis

            mee tooo

    • Candra Adi Putra

      add this code to manifest

  • palgun

    Hi Ravi,
    when i am trying to run this code i am getting this error in logcat,can anyone tell me the problem.
    thanks in advance.

    02-16 01:25:07.138: E/AndroidRuntime(1722): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.helloworld.googlemapsv2/com.helloworld.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class fragment

  • chin

    Hi,

    There is no map appear while run on real device.

    And there is an error of getFragmentManager and findFragmentById..

    Please help.

    Thanks

    • Solution

      I think that error occure when the android:minSdkVersion is inferior to 11. If you changed that in the Manifest the error is fixed. Sorry for the bad english. Cumps.

  • Kevin

    import com.google.android.gms.maps.MapFragment;
    import com.google.android.gms.maps.GoogleMap;

    after i adding this two comment, but still got error with the com.google.android.gms.maps.
    what to do. help!!

  • Arslan

    I have followed this tutorial step by step but every time i try, my application stops at the launcher activity before any thing is displayed on screen.
    LogCat snapshot is attached. plz help as i have got stuck here

    02-21 19:40:16.630: E/Trace(1300): error opening trace file: No such file or directory (2)

    02-21 19:40:18.481: D/AndroidRuntime(1300): Shutting down VM

    02-21 19:40:18.481: W/dalvikvm(1300): threadid=1: thread exiting with uncaught exception (group=0x40a71930)

    02-21 19:40:18.510: E/AndroidRuntime(1300): FATAL EXCEPTION: main

    02-21 19:40:18.510: E/AndroidRuntime(1300): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread.access$600(ActivityThread.java:141)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.os.Handler.dispatchMessage(Handler.java:99)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.os.Looper.loop(Looper.java:137)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread.main(ActivityThread.java:5041)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at java.lang.reflect.Method.invokeNative(Native Method)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at java.lang.reflect.Method.invoke(Method.java:511)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at dalvik.system.NativeStart.main(Native Method)

    02-21 19:40:18.510: E/AndroidRuntime(1300): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.Activity.setContentView(Activity.java:1881)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.example.MainActivity.onCreate(MainActivity.java:22)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.Activity.performCreate(Activity.java:5104)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

    02-21 19:40:18.510: E/AndroidRuntime(1300): … 11 more

    02-21 19:40:18.510: E/AndroidRuntime(1300): Caused by: java.lang.IllegalStateException: The meta-data tag in your app’s AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. You must have the following declaration within the element:

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.internal.q.v(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.internal.q.u(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.MapFragment$b.eb(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.dynamic.a.a(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.app.Activity.onCreateView(Activity.java:4716)

    02-21 19:40:18.510: E/AndroidRuntime(1300): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)

    02-21 19:40:18.510: E/AndroidRuntime(1300): … 21 more

    02-21 19:41:23.832: D/AndroidRuntime(1351): Shutting down VM

    02-21 19:41:23.832: W/dalvikvm(1351): threadid=1: thread exiting with uncaught exception (group=0x40a71930)

    02-21 19:41:23.871: E/AndroidRuntime(1351): FATAL EXCEPTION: main

    02-21 19:41:23.871: E/AndroidRuntime(1351): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread.access$600(ActivityThread.java:141)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.os.Handler.dispatchMessage(Handler.java:99)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.os.Looper.loop(Looper.java:137)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread.main(ActivityThread.java:5041)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at java.lang.reflect.Method.invokeNative(Native Method)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at java.lang.reflect.Method.invoke(Method.java:511)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at dalvik.system.NativeStart.main(Native Method)

    02-21 19:41:23.871: E/AndroidRuntime(1351): Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class fragment

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.Activity.setContentView(Activity.java:1881)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.example.MainActivity.onCreate(MainActivity.java:22)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.Activity.performCreate(Activity.java:5104)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)

    02-21 19:41:23.871: E/AndroidRuntime(1351): … 11 more

    02-21 19:41:23.871: E/AndroidRuntime(1351): Caused by: java.lang.IllegalStateException: The meta-data tag in your app’s AndroidManifest.xml does not have the right value. Expected 4132500 but found 0. You must have the following declaration within the element:

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.internal.q.v(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.internal.q.u(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.MapFragment$b.eb(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.dynamic.a.a(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.app.Activity.onCreateView(Activity.java:4716)

    02-21 19:41:23.871: E/AndroidRuntime(1351): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)

    02-21 19:41:23.871: E/AndroidRuntime(1351): … 21 more

    • luck

      make sure ur appliction tag must have these both tags…

      • Marco

        it didn’t solved to me, same error. Have you any other advice?
        thanks a lot 🙂

  • Guru Prasad

    Hello, thank you for your valuable tutorial.its working fine for me in all cases . i got a requirement like i need to place a custom layout as marker in google map. Custom layout contains 3 buttons and 2 imageviews 2 textviews its my requirement..could you please help how can i add custom layout as a marker ..Thankyou in advance ..please help me as soon as possible.

  • SIVARAMAKRISHNAN .V

    HAiii RAvi its a nice tutorial….

  • Ahmad Dwaik

    Impressive as always ravi, but on first run right after setup the project with google play service and provide fragment, an exception will be raised asking for play sevice version number! adding these couple of lines to manifest will fix:

  • Sonu Raj

    Hi I am getting this error:

    03-01 20:55:38.099: E/AndroidRuntime(6403): FATAL EXCEPTION: main

    03-01 20:55:38.099: E/AndroidRuntime(6403): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2306)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2358)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread.access$600(ActivityThread.java:156)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1340)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.os.Handler.dispatchMessage(Handler.java:99)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.os.Looper.loop(Looper.java:153)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread.main(ActivityThread.java:5297)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at java.lang.reflect.Method.invokeNative(Native Method)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at java.lang.reflect.Method.invoke(Method.java:511)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at dalvik.system.NativeStart.main(Native Method)

    03-01 20:55:38.099: E/AndroidRuntime(6403): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:274)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Activity.setContentView(Activity.java:1889)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:24)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Activity.performCreate(Activity.java:5130)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)

    03-01 20:55:38.099: E/AndroidRuntime(6403): … 11 more

    03-01 20:55:38.099: E/AndroidRuntime(6403): Caused by: java.lang.ClassCastException: com.google.android.gms.maps.SupportMapFragment cannot be cast to android.app.Fragment

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Fragment.instantiate(Fragment.java:585)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Fragment.instantiate(Fragment.java:560)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.app.Activity.onCreateView(Activity.java:4735)

    03-01 20:55:38.099: E/AndroidRuntime(6403): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)

    03-01 20:55:38.099: E/AndroidRuntime(6403): … 21 more

    • ajay

      make sure your appliction tag in ur manifest file must have these both tags…

      • Junita Pristi

        @ajay i was input as your comment, but its not working . what must i do ?

    • Junita Pristi

      i also get the same logcat like you, not yet solved 🙁

  • Mujeeb

    In Eclipse, the map was closed everytime i run it. How to fix this? Can’t we test in Eclipse?

    Secondly, when i installed the app on tablet, screen is coming up blank with just google logo at the bottom and zoom icons and no map is shown.

    Mujeeb.

    • IrieSoulJah

      same problem here …

      • black

        what do you mean by “same problem here”,??

        • IrieSoulJah

          WEll the blank screen … it was a problem with my google Account, after reinstalling it on the device, it worked out

          • black

            What have you reinstalled more exactely?

          • black

            ok..i’ve managed to get it up and running.The problem was with my key,my application package name was incorrect.thanks for the help anyway!

  • Joginder Sharma

    Hello Admin

    I want to know where to put this line
    googleMap.setMyLocationEnabled(true);

    I mean in which function.
    And Can we show the User Current location when he/she open the Map putting any code in manifest file or layout file not in Java file.
    Thank You

    • Pranav Bhatt

      @Override
      protected void onResume() {
      super.onResume();
      initilizeMap();
      googleMap.setMyLocationEnabled(true);
      }

  • steve

    Hey Ravi unable to download
    Plz help

  • Dipika

    how to develop android app for weather forecasting with GIS ??? plz help me

  • Adit

    nicely done. thanks it works!

  • Nehul Agrawal

    I tried this tutorial, but my app is getting force closed. i dont know where the problem is.
    from where i get this “@integer/google_play_services_version”
    and this “com.google.android.gms.version”

    Can someone help me with this?

    • Kim Youngsic

      You should add this source in your Manifest

      • Popovkov

        Thank you 😉

      • agriirga

        no resources found @ integer/

    • Pranav Bhatt

      i had also got this error…

      You should add this source in your Manifest in

      • Nehul Agrawal

        From where do i got this “google_play_services_version” and “com.google.android.gms.version”.

        Thank you for your concern.

        • Pranav Bhatt

          you can simpaly write under the application tag. no need to get from anywhere just write.

          • Nehul Agrawal

            I tried but it didnt work Please is there any another way i can get the same error?

          • jonathan

            thank youuuuu for posting a code snippet, I thought everyone was talking about the meta-data stuff that was already there at the bottom.

  • Manoj Nimbalkar

    Awesome work, it works nicely…thanks…

  • Stefy

    private void initilizeMap() {

    if (googleMap == null) {

    googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();

    // check if map is created successfully or not

    if (googleMap == null) {

    Toast.makeText(getApplicationContext(),

    “Sorry! unable to create maps”, Toast.LENGTH_SHORT)

    .show();

    }

    }

    }

    its showing error saying MapFragment can’t be resolved . What to do

    • needhelp

      That error is obvious no ?.Google Play Services Library is not attached to your project thus Eclipse is unable to find the class called MapFragment.

  • Bella

    The map is not showing on physical device.How would I solve this? Please help!

    • Diomede

      As somebody else has already written in comments: You should use apk file from bin folder of the project saved on your computer rather than export project from IDE… that was solution in my case!

      • IrieSoulJah

        in my case I can see the “google” and +/- symbol but no map … any suggestions?

        • Diomede

          I’ve had same situation… Be very careful when editing Androidmanifest.xml file as u have to be sure that you have your own package name everywhere needed (4 times replace info.androidhive.googlemapsv2 with yours)

          package=”info.androidhive.googlemapsv2″

          android:name=”info.androidhive.googlemapsv2.permission.MAPS_RECEIVE”

          android:name=”info.androidhive.googlemapsv2.MainActivity”

          I’ve also added this line:

          Otherwise i’ve followed instructions above and it works!

          • IrieSoulJah

            Thanks for the reply!
            But my problem was solved by reinstalling my google account on the device … didn’t think about that but it worked

          • $neha

            It gives activity not found exception
            and toast the unable to create map

        • anonymous

          you should change the sha1 key

          • IrieSoulJah

            Nope, I had to reinstall the google account on my device, that worked out!
            Thanks anyway

        • wael

          me too !! i’ve the same problem only google and + – no map even no toast 🙁
          i ve changed the sha1 key for several time and i change my google account and it’s the same !!

          • IrieSoulJah

            Try to reinstall your googleAccount from the device, worked out for me!

  • Ankit Aggarwal

    How can we hide the name of the countries in the normal map type in Android Google Maps v2. I want political boundaries, but no name.

    • Anuraag Ashok Kumar

      I too need a solution for this. Please reply anyone.

  • zionkoh

    googleMap.getUiSettings().setMyLocationButtonEnabled(true); where do i put in this code?

  • zionkoh

    googleMap.setMyLocationEnabled(true); // false to disable where do i put in this code?

    • needhelp

      @Override
      protected void onResume() {
      super.onResume();
      initilizeMap();
      googleMap.setMyLocationEnabled(true);
      }

      setMyLocationEnabled() and setMyLocationButtonEnabled() is not the same by the way

  • Maryam

    I have tried tried this code but it give error when i run it “Unfortunatialy Google Map V2 Has Stop”

  • zion

    how to add multiple marker?

  • francesco

    I got the following error:

    E/AndroidRuntime(2548): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.smpparking/com.example.smpparking.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    what shoud i do to fix it?

    • Aman Deep

      Did you put

      in manifest file ?

      • amit

        i have added all permission den also facing same problem

        • Aman Deep

          Can you show the logcat?

          • Arun Shankar

            You should add the
            <meta-data android:name=”com.google.android.gms.version” android:value=”@integer/google_play_services_version”/>

            in your manifest file under the application

          • Jacek Wojcieszyński

            I got namespace conflict by using twice android:name for meta-data

        • $neha

          I am facing same problem ..

          what shoud i do to fix it?

  • Sajad Vafa

    How can I show the route between two points?

  • Aditya Delightful Guy

    how to share the current location in the map by capturing

  • Vibhuti

    just awesome.. Can you please help me to draw route between two points?? i am done till given in the project..

  • Problems with Maps V2

    I’m getting this error on logcat “unable to resume activity : java.lang.NullPointerException”. Anyone else got this error? Any solutions?

  • dev

    I have followed each and every step and also have used SupportMapFragment but everytime am facing this error “java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment”.

    • dev

      Any reply will be appreciated..

      • Arun Shankar

        You should add the

        in your manifest file under the application

  • $neha

    I got error on fragment

    when comment on it can not stop

    but fragment is there it got lots of error such as activity not found,google play service etc and unfortunately stop the app

    how i fix it?

  • Carlson

    i couldn’t launch the application in my phone and it instantly closed 🙁 what happen to it? i follow the steps till step 6 and then i try to launch in my phone..but it didn’t work..anyone help? tq

    • Antonio

      Hi,
      i had same problem in Android 2.2. I had not this when i run the same .apk in another android device (Galaxy Note) with 4.1.2 Android Version.

  • cha

    The app is running without any errors, but i’m getting a blank screen! Anyone know what it could be because of?

    • Sid

      First time I launched my app, I had to wait few seconds too see something to happen and after… It was magical ! 😀 Thanks to the autor for the best tuto in order to use Google Map in an app 😉

    • smallant

      It can be because of the SHA1 key. Check if its all ok with the key and if your app id is correct in the manifest

    • arniotaki

      I see the same blank screen while loading the app for first time. Do I have to turn wifi on to make it work? That way it works!

      • Nourhan

        Did you solve this problem?

      • Nourhan

        If you remember solving this problem please let me know as I am facing the same problem.

    • Vivek Priyadarshi

      hey buddy …

      i think you have problem in manifest file …check your package name in manifest…Is everything fine

      hope this will help you

      cheers……

  • Bhupendra

    Please add following into manifest file

    • gocshare

      thank a lot 🙂 you saved my night

      • Bhupendra

        Welcome

    • jignesh suvarna

      Thanks a Lot @Bhupendra “ur truely a STAR “, by the way how did u know that was the problem ??

      • Bhupendra

        Thanks,

        I got hint from logcat , where it was asking for meta-data.

        • jignesh suvarna

          Nice 🙂 , by the way have you manged to run the Google Places and Maps Tutorial ? i am getting “Places Error Alert box , mentioning Request Denied !”
          and can see blank map.
          any help would be appreciated 🙂

          • Bhupendra

            can give your mail id i will mail you code

          • jignesh suvarna

            Hi Bhupendra , my email id is: jigneshsuvarna@gmail.com
            Thanks for your help !

          • amel

            HI @disqus_jdA9NWluu7:disqus please mail me your code.my mail is amel.arfaoui@supcom.tn

          • alek

            What are your problem? if you download the code of the site, add your own API key, it works.

          • Guest

            Hi @disqus_jdA9NWluu7:disqus , pls mail me your code
            i got a blank map. My email is faizah.021@gmail.com
            thanks

          • linda izza

            hi @disqus_jdA9NWluu7:disqus please mail me your code
            i got a blank map
            my mail is: faizah.021@gmail.com

        • Sagar

          Please send me code to solve “blank map screen”.
          my emailId is sagar.vadaria90@gmail.com

    • udith isuru

      thanks very much i get error and find what’s wrong.finally i find this commend.thanks very much u save my day

      • Bhupendra

        Welcome

    • Jacek Wojcieszyński

      I can not use android:name attribute twice in meta-data. What should be the syntax of below?

  • SundaraManikandan

    Whenever iam running the code it is showing

    04-11 16:38:41.171: E/AndroidRuntime(7807): FATAL EXCEPTION: main

    04-11 16:38:41.171: E/AndroidRuntime(7807): Process: info.androidhive.googlemapsv2, PID: 7807

    04-11 16:38:41.171: E/AndroidRuntime(7807): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread.access$800(ActivityThread.java:135)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.os.Handler.dispatchMessage(Handler.java:102)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.os.Looper.loop(Looper.java:136)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread.main(ActivityThread.java:5017)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at java.lang.reflect.Method.invokeNative(Native Method)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at java.lang.reflect.Method.invoke(Method.java:515)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at dalvik.system.NativeStart.main(Native Method)

    04-11 16:38:41.171: E/AndroidRuntime(7807): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.Activity.setContentView(Activity.java:1929)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:24)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.Activity.performCreate(Activity.java:5231)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)

    04-11 16:38:41.171: E/AndroidRuntime(7807): … 11 more

    04-11 16:38:41.171: E/AndroidRuntime(7807): Caused by: java.lang.IllegalStateException: The meta-data tag in your app’s AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the element:

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.common.GooglePlayServicesUtil.t(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.internal.q.B(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.internal.q.A(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.MapFragment$b.gW(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.dynamic.a.a(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.dynamic.a.onInflate(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.app.Activity.onCreateView(Activity.java:4785)

    04-11 16:38:41.171: E/AndroidRuntime(7807): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)

    04-11 16:38:41.171: E/AndroidRuntime(7807): … 21 more

    • bij

      same problem here!!

      • jeeva

        just you add below code in your manifiest file.

  • nadhems

    cool it’s worked in my emulator

    • Mohye Ajluni

      set your emulator target :Google APIs(Google Inc)-API level#

  • priyanka

    I have followed every step but my emulator is taking much time. I have 3 GB RAM please suggest me to what SDK target I set for my avd.

    • vinoth

      you better test in your app it will be fine helpful for you.

  • Mubarak V Kabees

    SIr., your Google Maps API key (CMD) are not working.. pls change your

    Google Maps API key for Windows 7 to my API its working properly

    “PATH OF KEYTOOL>EXE”>keytool.exe -list -v -alias androiddebugkey -keystore “PATH OF KEYSTORE.androiddebug.keystore -storepass android -keypass android

    the KEYTOOL.EXE in the java SDK directory

    my Google Maps API key cmd command is “”” C:SunSDKjdkbin>keytool.exe -list -v -alias androiddebugkey -keystore C:UsersLakGroup.androiddebug.keystore -storepass android -keypass android “”””

    pls change it. is a request.. and it is helpful for your visiters.., Thank you

  • Murad Tukan

    i have done the steps perfectly please help , i dont know why the app crashes:

    04-24 21:23:25.976: D/AndroidRuntime(15696): Shutting down VM
    04-24 21:23:25.976: W/dalvikvm(15696): threadid=1: thread exiting with uncaught exception (group=0x41876898)
    04-24 21:23:25.976: E/AndroidRuntime(15696): FATAL EXCEPTION: main
    04-24 21:23:25.976: E/AndroidRuntime(15696): java.lang.RuntimeException: Unable to start activity ComponentInfo{info.androidhive.googlemapsv2/info.androidhive.googlemapsv2.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2349)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread.access$700(ActivityThread.java:159)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1316)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.os.Handler.dispatchMessage(Handler.java:99)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.os.Looper.loop(Looper.java:137)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread.main(ActivityThread.java:5419)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at java.lang.reflect.Method.invokeNative(Native Method)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at java.lang.reflect.Method.invoke(Method.java:525)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at dalvik.system.NativeStart.main(Native Method)
    04-24 21:23:25.976: E/AndroidRuntime(15696): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:719)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.inflate(LayoutInflater.java:498)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:361)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Activity.setContentView(Activity.java:1956)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at info.androidhive.googlemapsv2.MainActivity.onCreate(MainActivity.java:23)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Activity.performCreate(Activity.java:5372)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2257)
    04-24 21:23:25.976: E/AndroidRuntime(15696): … 11 more
    04-24 21:23:25.976: E/AndroidRuntime(15696): Caused by: android.app.Fragment$InstantiationException: Trying to instantiate a class com.google.android.gms.maps.SupportMapFragment that is not a Fragment
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Fragment.instantiate(Fragment.java:584)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Fragment.instantiate(Fragment.java:560)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.app.Activity.onCreateView(Activity.java:4958)
    04-24 21:23:25.976: E/AndroidRuntime(15696): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:695)
    04-24 21:23:25.976: E/AndroidRuntime(15696): … 21 more
    04-24 21:23:25.976: E/AndroidRuntime(15696): Caused by: java.lang.ClassCastException
    04-24 21:23:25.976: E/AndroidRuntime(15696): … 25 more

    • Mubarak V Kabees

      you are RUN the app in AVD, the Google Play Service not work in AVD.., pls connect your Android phone and run the app inside the phone.., i have the same error

  • Ishrat

    plz help, whenever i ran that app in my emulator it says “This app wnt run without google play service ,which is missing in ur phone” although i have install google play service successfully and import it . also i add in the manifest and set emulator target :Google APIs(Google Inc)-API level# ans plz any1…..

  • SundaraManikandan

    To find your sha1 key in eclipse go to windows->preferences->Android->Build, after then u can find the MD5 and SHA1 fingerprint on the right hand side.

    Thanks and Regards,
    SundaraManikandan.L

  • nkin

    05-02 21:06:33.563: E/AndroidRuntime(984): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.softmobile/com.example.softmobile.MainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.ActionBarContainer

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1736)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread.access$1500(ActivityThread.java:123)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.os.Handler.dispatchMessage(Handler.java:99)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.os.Looper.loop(Looper.java:126)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread.main(ActivityThread.java:3997)

    05-02 21:06:33.563: E/AndroidRuntime(984): at java.lang.reflect.Method.invokeNative(Native Method)

    05-02 21:06:33.563: E/AndroidRuntime(984): at java.lang.reflect.Method.invoke(Method.java:491)

    05-02 21:06:33.563: E/AndroidRuntime(984): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)

    05-02 21:06:33.563: E/AndroidRuntime(984): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)

    05-02 21:06:33.563: E/AndroidRuntime(984): at dalvik.system.NativeStart.main(Native Method)

    05-02 21:06:33.563: E/AndroidRuntime(984): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.v7.internal.widget.ActionBarContainer

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.createView(LayoutInflater.java:596)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:671)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:783)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.rInflate(LayoutInflater.java:720)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.inflate(LayoutInflater.java:479)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.inflate(LayoutInflater.java:391)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.inflate(LayoutInflater.java:347)

    05-02 21:06:33.563: E/AndroidRuntime(984): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:224)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.Activity.setContentView(Activity.java:1777)

    05-02 21:06:33.563: E/AndroidRuntime(984): at com.example.softmobile.MainActivity.onCreate(MainActivity.java:18)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700)

    05-02 21:06:33.563: E/AndroidRuntime(984): … 11 more

    05-02 21:06:33.563: E/AndroidRuntime(984): Caused by: java.lang.reflect.InvocationTargetException

    05-02 21:06:33.563: E/AndroidRuntime(984): at java.lang.reflect.Constructor.constructNative(Native Method)

    05-02 21:06:33.563: E/AndroidRuntime(984): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.view.LayoutInflater.createView(LayoutInflater.java:576)

    05-02 21:06:33.563: E/AndroidRuntime(984): … 23 more

    05-02 21:06:33.563: E/AndroidRuntime(984): Caused by: java.lang.NoClassDefFoundError: android.support.v7.appcompat.R$styleable

    05-02 21:06:33.563: E/AndroidRuntime(984): at android.support.v7.internal.widget.ActionBarContainer.(ActionBarContainer.java:59)

    05-02 21:06:33.563: E/AndroidRuntime(984): … 26 more

    • Chaya Sandamali

      Thank you..It helped a lot.:D

  • Francesca

    Hi thank you very much for you tutorial, I just have one question: when the gps is enable (the button appears with mMap.setMyLocationEnabled(true); )everything works but when gps is disable nothing happens, I mean setting locations don’t open. How can I do it?

  • Nidhin Raj

    I have tried this code but getting an error when i run it “Unfortunatialy Google Map V2 Has Stop” .

    • N Mahmoud Amry

      i have the same problem, how did you get rid of it

      • Vivek Priyadarshi

        put this- code in menifest.xml

        i think [this will work for you

        • smiler

          the same problem here, do i should replace this code:
          with this:
          ???

          • needhelp

            This is because the android emulator does not have Google play services you are required to run this app on a real device.

          • smiler

            I did that but i get the same problem :/

  • Nidhin Raj

    Google Map V2 is not working in android 2.2 ?

  • Hi! I have some problem ! Can you help me?? Please It’s important for me!

    05-21 14:30:42.651: E/AndroidRuntime(1129): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tutorialandroidgooglemap/com.example.tutorialandroidgooglemap.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment

  • Varad Choudhari

    I’m adding this code to my project, but there seems a weird error. Can you help me fix it?

    The screenshots:

    http://i.imgur.com/dHfzCwg.png

    http://i.imgur.com/9ndyFD0.png

  • Ramiro Anacona Meneses

    Hi, thanks for sharing your knowledge.

    This example does not work, the solution: in the manifest.xml file add:

    After Maps API Key.

    Thanks

    • Sna

      Thanks. Problem solved 🙂

    • Ky

      LOVE YOU! lol

    • ilija

      if only i saw your post before going through the documentation

    • Ankan

      Thanx dude

    • kamran

      love u man

  • Irfan Tri Handoko

    how i can get multiple map markers values from JSON ?

  • Guest

    There is some problem in this code,
    In Manifest.xml file inside meta-data tag these lines should be added or can be added under application tag independently. I think that’s why people are getting force close error.

  • arniotaki

    Hello,

    I used your code. Is it possible while loading application for the first time to show the map instead of a blank area with the google sign on the bottom left?

  • Ram

    Hi,,,

    I have using this program on my coding it will running successfully on emulator and shows the google Maps..but if i take APK file and install at my mobile it will not shows the google maps it will shows “Grey color tiles”what can i do now,, if any one know about this reply for me..

    Thanks 🙂

  • mustafa

    Application wont run. It says application has closed unexpectedly. Force Close! plz can u suggest what to do..

  • Bruno Casado

    I’m using this code as base for mine and it works perfectly when the cell phone is connected to the computer, but when I try to use the application on my cellphone and its not connected to the computer, the map does not open.

    When I’m running it on the computer I get some errors, but the map still open. Here are some errors:

    07-07 16:15:42.787: W/dalvikvm(28675): VFY: unable to resolve static method 24936: Lguj;.a (Landroid/content/Context;)Lgri;

    07-07 16:15:42.787: W/dalvikvm(28675): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

    07-07 16:15:42.787: W/dalvikvm(28675): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

    07-07 16:15:42.787: W/dalvikvm(28675): VFY: unable to resolve new-instance 4090 (Lgpr;) in Lgps;

    07-07 16:15:42.797: W/dalvikvm(28675): VFY: unable to resolve static field 20873 (t) in Lyp;

    07-07 16:15:43.987: W/dalvikvm(28675): VFY: unable to resolve static field 20873 (t) in Lyp;

    07-07 16:15:44.167: W/dalvikvm(28675): Link of class ‘Lcom/google/android/gms/location/internal/ParcelableGeofence;’ failed

    07-07 16:15:44.177: W/dalvikvm(28675): VFY: unable to resolve check-cast 2086 (Lcom/google/android/gms/location/internal/ParcelableGeofence;) in Lglt;

    07-07 16:22:25.957: W/dalvikvm(28675): Link of class ‘Lcom/google/android/gms/location/internal/ParcelableGeofence;’ failed

    07-07 16:22:25.957: W/dalvikvm(28675): VFY: unable to resolve static field 4203 (CREATOR) in Lcom/google/android/gms/location/internal/ParcelableGeofence;

    Do you have any ideia why it happens? I’ve already check for my SHA1 key and it’s ok.

    • Bruno Casado

      I’ve already find out why it was happening. I created a SHA1 key as you said but when I exported the apk I used another key with a different SHA1 key and didnt realize that. Now It’s working perfectly 😀

  • Anjy

    Awesome tutorial.. But m unable to change the color of the marker.

  • Kiki Skylite

    hi,,,

    I just made ​​a google maps project, the eclipse v22.6.1. after I created and I run, I get an error message “failed to contact google servers. another attempt will be made ​​when connectivity is established” and in the emulator maps does not appear

    Can anyone help me? thanks

  • bharat

    Can anyone tell me that how i can shift compass button to right top corner..
    i am just tired to searching that… help me…

  • Simarjot Singh

    this code not working, It gives an error “Unfortunately Google map stopped” plzz give me solution to this error…

    • one

      In Manifest.xml file inside meta-data tag these lines should be added or can be added under application tag independently. I think that’s why people are getting force close error.

      <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version"/

  • Toams Kruty

    Ok so I did this step by step, even copied the codes so I don’t make any silly mistakes and still when I run it on my HTC it is shutting the app unexpectedly, where might be the problem? I imported all the libraries, I have the key and I have no idea where else can the problem be

  • mrdm

    1 important issue:
    when u change “android:minSdkVersion” in manifest , u most recieve a new api key from Google APIs Console

  • rag

    Add these 2 lines in Android Manifest to the existing code

  • Kumar

    Hi,can anyone explain how to get current location with out using GPS….
    thanks

  • Yogesh Seralia

    I have got this error message in logcat while launching this app in AVD emulator
    :

    07-30 11:43:51.906: E/AndroidRuntime(724): FATAL EXCEPTION: main
    07-30 11:43:51.906: E/AndroidRuntime(724): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
    07-30 11:43:51.906: E/AndroidRuntime(724): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
    07-30 11:43:51.906: E/AndroidRuntime(724): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.Activity.onCreateView(Activity.java:4242)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
    07-30 11:43:51.906: E/AndroidRuntime(724): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.Activity.setContentView(Activity.java:1835)
    07-30 11:43:51.906: E/AndroidRuntime(724): at info.androidhive.info.MainActivity.onCreate(MainActivity.java:18)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.Activity.performCreate(Activity.java:4465)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.ActivityThread.access$600(ActivityThread.java:122)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.os.Handler.dispatchMessage(Handler.java:99)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.os.Looper.loop(Looper.java:137)
    07-30 11:43:51.906: E/AndroidRuntime(724): at android.app.ActivityThread.main(ActivityThread.java:4340)
    07-30 11:43:51.906: E/AndroidRuntime(724): at java.lang.reflect.Method.invokeNative(Native Method)
    07-30 11:43:51.906: E/AndroidRuntime(724): at java.lang.reflect.Method.invoke(Method.java:511)
    07-30 11:43:51.906: E/AndroidRuntime(724): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    07-30 11:43:51.906: E/AndroidRuntime(724): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    07-30 11:43:51.906: E/AndroidRuntime(724): at dalvik.system.NativeStart.main(Native Method)

    • Hi Yougesh,

      Its because emulator doesn’t have play services installed. Try to run the project in a real device.

  • tinos

    hello
    any option if i fail to check copy project to workspace.

  • Circuit Solutions

    hello good day mag application says sorry unable to create map

  • Rajeev

    thank you … good work it really helped a lot

  • Hamad ali

    I use Geo Encoder and use function List addresses = geocoder.getFromLocation(latitude, longitude, 1);
    But it give Service not found Exception Plz any body help me

    • Reboot your device once and check it..
      Geocoder class in the latest version won’t work well.
      Instead of using Geocoder class you can use google services

  • Thomas Kioko

    Hi Ravi,

    I need some help/advice. I want to create an Android app that enables guys to share their location (real Time) with other user who have the app. How do I go about that?

    • Phuong Huynh

      You can use socket to connect devices and share their GPS coordinate, I’m also doing that (in the same your idea :D)

    • Rahul Srivastava

      Get current location and send it to another user via push notification. I’m doing so and it is working fine 🙂

  • vivek

    Hi Ravi,
    It’s not working I got this error…

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.samplemap/com.example.samplemap.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment.

    • Sarini Tharindya

      pls add this in to androidManifest file afer meta-data tag.

      Try it. 🙂

  • Abhilash .K.V

    hai Ravi,
    How to implement Google Map in Fragment Class please help me, thanks

  • Steve Kelly

    Hello Ravi, I met an Indian guy in the Pyreneess in France in 2006 , we were just chatting on a bus he said to me, ” In india programmers are artists with code”, after seeing your work I realise now what he meant.
    I got stuck with the last bit on this tutorial number 6 mainactivity.java class. Do I delete what’s already in there and replace with your code?
    Best wishes
    Steve
    keep up the good work

  • Gilmar François

    It works perfectly, but I needed to put some meta data

    inside into AndroidManifest.xml

    and Generate Signed APK and install with adb (both emulator or real device works).

    Android Studio 0.8.6

    Thanks Ravi.

  • Muhibun Syairoji

    hello,
    i have a project using apikey V1. and it is not runninng well now.. how to convert from apikey v1 to v2 ? because in v1, we have to put apikey in main.xml but in apikey v2 we put apikey in androidmanifest. .. please help me…
    thank you

  • Manu

    Great tutorial
    Just a question: if I write a false api key in the manifest file, the app works fine on a real device. So, what is that key for?
    Thanks in advance

    • Cyber

      really? it didn’t work for me. Maybe looking for unoccupied keys and the false one is unoccupied?

  • Karthee Karthee

    [unnamed-8170-1](this:0x51738f28,api:1) dequeueBuffer: min undequeued buffer count (2) exceeded (dequeued=1 undequeudCount=1) and Failed to load map. Error contacting Google servers. This is probably an authentication issue (but could be due to network errors).i got this error

  • darshak

    how to add multiple marker on same location.?

    • Cyber

      doesn’t it work with different marker variable when you add to map?

  • Anupreet Kaur

    how to draw a line when i have 5 lat lng

  • Anupreet Kaur

    i want to draw a line when user start from a point till when he reach his destination….can anyone help for this

    • Sunil

      Hi, u want to draw a line or route path between user and destination???????

  • neelam

    as i mam running my app with the same code as given above, its saying library project cant be launched.pls help me how to sort this problem

  • neelam

    previous problem has been sorted out. now the new problem is
    [2014-09-18 10:01:48 – GoogleMapsV2] Using 1.7 requires compiling with Android 4.4 (KitKat); currently using API 12

    pls hepl what to do

  • Cyber

    (i at least try to apply the map viewing part, that’s where i stuck i believe)

    java.lang.RuntimeException: Unable to start activity ComponentInfo{packagename}: android.view.InflateException: Binary XML file line #11: Error inflating class fragment –

    <- i keep getting this error. i saw people with same problem saying it is either because of either i'm not extending the activity as fragment activity (was it necessary?) or i didn't import these

    import android.support.v4.app.Fragment;

    import android.support.v4.app.FragmentActivity;

    – practically the same i guess. Any idea how can I fix this? I'm working on indigo's last version as ADT and test device is api 4.1.2.

    • Cyber

      update: I solved the problem it seems pretty common.

      My problem was forgetting this:

      I tried LocaiıonManager tutorial once, so i used it there. But in this tutorial, this is missing, so line #11 is only layout file indicates the package path of the fragment component.

      In case anyone else mistake or forget the other common solutions:
      – API level should be at least 8 (might be 12 as well. )
      – Add library like above, not through Java Build section
      – If you have Map Demo project(the one provided in developer.android) in the workspace it is recommended to move.
      – Test device needs GPS. I think if you have an adaptor for it, you should be able to enable it for your virtual device. But if not, connect a physical device.

  • Bung Nanank

    how to get value latlng in geolocatoin

  • Kid

    Unfortunately, Google maps v2 has stopped ! Sir

    • Sudeep

      Did you get any solution for this ?

  • Piyush Gupta

    All is good. But If i want to move my google map with my current location move so how can i do that? i have used CameraFactoryUpdate for animate camera on onLocationChanged() method. I need same as a default google map

  • Sanjay M

    As I am using this same code in fragment the onResume method is not getting called. When I come back to the fragment by navigation drawer its not getting resume. Its simply getting closed.

  • saish neugi

    i am getting the following error “Unable to execute dex: Multiple dex files define Landroid/UnusedStub;”

    Anyone who knows the solution

    • saish neugi

      I found the ans to this, in case anyone come across such issue. Check your jar files . You might possibly have a duplicate entry of google-play-services_lib

  • Nha

    meaningful lesson ive ever learn about maps ! Thanks

  • Tom Lo

    Please update this tutorial the sample download don’t work.

    • SundaraManikandan

      what’s the problem u r facing?

  • priya

    Showing error “GoogleMap cannot be resolved to a type “

    • Hemal Adani

      For googleMap you have to have import of
      import com.google.android.gms.maps.GoogleMap;

      If you your app doesn’t allow this import. Then you have to add googleplayservices into your project.
      Let me know if you have any further issues.

      • sd vipeen

        i cant import import com.google.android.gms.maps.GoogleMap;..So i added googleplay services to my proj..yet i get the error..any idea how to solve this.?

  • Bhagyasri Patel

    I have follower this tutorial. But i’m getting error:Please help me.

    Could not find class ‘com.google.android.gms.maps.MapFragment’, referenced from method com.google.android.gms.MainActivity.initilizeMap
    11-14 13:27:20.966: W/dalvikvm(1718): VFY: unable to resolve check-cast 686 (Lcom/google/android/gms/maps/MapFragment;) in Lcom/google/android/gms/MainActivity;
    11-14 13:27:20.966: D/dalvikvm(1718): VFY: replacing opcode 0x1f at 0x000b
    11-14 13:27:21.027: D/dalvikvm(1718): DexOpt: unable to opt direct call 0x12bb at 0x25 in Lcom/google/android/gms/MainActivity;.initilizeMap
    11-14 13:27:21.027: D/dalvikvm(1718): DexOpt: unable to opt direct call 0x12bc at 0x2c in Lcom/google/android/gms/MainActivity;.initilizeMap
    11-14 13:27:21.256: D/AndroidRuntime(1718): Shutting down VM
    11-14 13:27:21.267: W/dalvikvm(1718): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
    11-14 13:27:21.286: E/AndroidRuntime(1718): FATAL EXCEPTION: main
    11-14 13:27:21.286: E/AndroidRuntime(1718): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.gms/com.google.android.gms.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
    11-14 13:27:21.286: E/AndroidRuntime(1718): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)

    • AS10

      Try to use android:name instead of class

  • Praveen

    Thank you so much, for the details, and Download code, It helped me to see the Maps… here. Thank you.

  • Nitish

    can you tell me hot to change position of current location button

  • baskar

    can anyone tell me how to implement googlemap v2 in Actionbar tab.

  • Rameez

    Thanks! nice tutorial

  • vishal

    how i know its latitude or longitude while touch on map screen

  • Aditya Sharma

    can we use same API KEY in other application ??

    • Ashok Sangaru

      api key generation is for one time you can use many times

  • hash95

    Hello,

    Nice tutorial. I’ve an issue. I did everything like you but when I try to run the project, I’ve this erorr : “Binary XML file line #6: Error inflating class fragment”

    I’ve searched a lot on internet, but I’ve found nothing helpful.

    Thx

    • AS10

      Try to see your log scroll down you will see other problem related to your meta data and permission .Solve them and your error will be removed . In your meta data problem it will say it didn’t found meta tag in your manifest file .Try to put your meta tag inside your application tag.

      • AS10

        Try to add this meta tag:

    • Mehmetcan Tas

      Add below tags between tags on your manifest.xml

  • Curious

    Hi,

    I’ve done everything you said in your Google Map V2 tutorial! but my app crashes…

    Could you please help me?

    http://stackoverflow.com/questions/27905561/android-map-v2-program-crashes-at-start

    tanx a lot

  • Yatin Verma

    Hi Ravi,

    Thanks for your excellent presentation. Great info for android app development lovers. I have been following your previous tutorial, they are good. In this tutorial, i follow every step of yours but i am getting this error at runtime…. Can you please tell me the issue and recommended solution…
    I have already added Android key and Google Play version metadata in AndroidManifest

    Binary XML File error:

    Error inflating class fragment

    at android.app.ActivityThread.performLaunchActivity

    at android.app.ActivityThread.handleLaunchActivity

    at android.os.Handler.DispatchMessage

  • Ashok Sangaru

    hai ravi
    you did wonderful job and and waiting for design so when do u start start ravi

  • Willy

    the author forgot

    in the Manifest just before

    And to turn on the Google Android Map v2 you have to go to the ‘old’ console API. Otherwise you cannot find the ‘Service’ easily.

    good luck !

    • sd vipeen

      I added

      in my manifest..but i still get the Error “GoogleMap cannot be resolved to a type”

      Is there any other way.?

      • chemechaos

        in android studio don’t forget to add the following in the build.gradle

        dependencies {

        compile fileTree(dir: ‘libs’, include: [‘*.jar’])

        compile ‘com.android.support:appcompat-v7:21.0.3’

        compile ‘com.google.android.gms:play-services:6.5.87’

    • Amartya

      Thanks Willy! For those who are getting the error “Binary XML File error: Error inflating class fragment”, this solution might work for you all…I was getting the same error. I’m using eclipse.

  • Mardoqueu Sousa

    Could you make a tutorial about Web Server + Google Maps v2 + SQLite? specific about marks, I mean if I want to put more marks on the App instead of to put on the code and upload again into the device I just send using the web server to App and it saves the new marks on the APP using SQLite. Do you know how to do that?

  • Guest

    I added

    in my manifest..but i still get the Error “GoogleMap cannot be resolved to a type”

    Is there any other way.?

    • needhelp

      Your development envirement is not recogniizing the GoogleMap class this means you did not add the google play services library to your project (this is explained above)

  • Caramille

    thank’s it work but took me one day ’cause the app was crashing at the launch I had to put “android:name=”com.google.android.gms.maps.SupportMapFragment” in the fragment

    • sandhya

      hi ,where did you add it? i am not able to add it , did you replace the MAPS_RECEIVE fragment or what did you do? is this rite? why does my app crash when i tried to execute?

  • Ram

    Thank you so much.it was really helpfull!!

  • Jeyatharsini

    It was really helpful… but for people who use emulators should use Google API as target… better to specify it also.. 🙂

  • harl

    hi is this thread still going? i manage to run the app but it only shows black screen.. it doesn’t show the map.. please help.. thanks a lot..

    • needhelp

      How are you running your app ? on a real device or an emulator ? most likely something is wrong with android permissions and or your code also note you need google play services to be able to run apps that display maps.

      • harl

        thanks for the reply.. I already figured out what’s the problem on my app.. the next thing I need to do is how will I implement my current location on the map.. thanks..

        • needhelp

          So if i get this right you want an app that opens a map and displays your current location ?.There is an example in the google play services samples that demostrates this what you need for this is called the FusedLocationApi

  • alek

    Hey does anyone know how to add an array of markers and display it, with a different icon for each type of marker in the array?

  • Shahin fathima

    Does above code works in android 4.2.2 ?

    • alek

      Yes, it does.

      • Shahin fathima

        thanks yaar . Got it

  • Airton Toyansk

    And how does to implement the search bar just like the Google Maps app?

  • sandhya

    hi,
    I did everything the author has said but i am using android studio, my app crashes when i run it, do i have to do something different from Eclipse in android studio? how do i do it?

    Thank you!

  • Hi,
    I have follow this tutorial, But i’m getting error.
    Please help me, Syntax and error log -> http://pastebin.com/KbhqSbtN
    Thanks

  • mehdii

    hi ,
    I did everything the author has said but the map wont load
    it appears the word “GOOGLE” down of the page, but the map does not appear

    • Mohsen

      I have same problem mehdi jaan!

      • viviswt swt

        enable google Map API in console.developer.google.com

  • rokas

    I’ve loved every tutorial in this website. They’re extremely user-friendly, especially for beginners, with comprehensive explanations, and this one is not an exception. It’s so simple and clear, without any unnecessary points — only the targeted topic at its clearest form. I could only recommend to the writer to be more thorough when writing such tutorials, as sometimes a little typo in the code may totally mislead a complete beginner and cause a huge mess for him. Thank you for such a great source of information!

  • Mardoqueu Sousa

    Could you make a tutorial about Storing Google Maps Android API V2 marker locations in MySQL with the option for whatever title I want? ’cause I saw this tutorial: http://wptrafficanalyzer.in/blog/storing-google-maps-android-api-v2-marker-locations-in-mysql/ but I can’t modify it to put titles instead of latitude and longitude

  • Nadeem Ilyas

    You Rock Ravi.. I have tried to implement google maps for 5 days. FInally I saw your tutorial. It is really simple and awesome. Great work.

    It was not working for me but after doing only two changes, it worked for me.

    Here are those two changes for those who are not able to see map(but they can see a white/black background with google word on bottom left corner).

    I added these line in Manifest.xml above api key meta-data tag.

    And secondly, In activity_main.xml, I changed

    to

    and it worked perfectly for me..

    • Leo Rich

      Hey Nadeem Ilyas.

      Nice work. after i followed your update every thing work great

    • Atif Afridi

      thanks a lot bro i had the same problem but ur code helped… can u plz tell why u made the changes i mean the tutorials os correct for other but not for you and me

  • Mustajab Hussain

    I got error : Unable to connect to google api client

    Any Help?

    • Raja

      add below version in tag. It will work.

  • narinder

    hello sir,

    google maps v2 won’t run unless you update google play services and update button on the AVD

    what i will do?for see google map

  • Raj

    I need your Guide,

    I have little bit experience in Eclipse. But i am new to Android Studio, in one of my Android application i can load the map and use it by running from IDE, But After putting it on play store i unable to load the map.

    I have experience to using Google map on Android for the past 3 years. But this issues is new for me.

    If i use the same steps to create Map Application by using Eclipse it is working fine after Launching on play store. But In Android Studio

    1) i have build apk as release mode,
    2) My SHA1 key also correct

    The Android Studio will create the Dubug Key automatically. But even i build the APk in release mode , it not let me load the map..,

    Please Guide Me..,

    Thank You!

    Have A Happy Day..,

  • sachindra

    One of the Best Tutorial, Just change a little bit, and work smoothly:)

  • Hello Ravi, Thanks for your best tutorial
    I have question, How Record my Movements With Google maps android and GPS coordinate?
    I’ve tried to make it a way to connect multiple Placemark manually (with polyline), but I had difficulty to make realtime connect when i movements.
    Have you ever done this before?
    please give me the reference.

    • Alex777

      @yayan, did you find an answer? I am also trying to create a function which tracks my movement realtime and draws a polyline.

  • When moving to v2 of the Maps API for Android, you’ll immediately notice that this is a completely new API with very little regard to backwards compatibility .

    How to Migrating from v1 maps to v2 maps in Android -> http://geekonjava.blogspot.co.uk/2015/06/migrating-from-v1-maps-to-v2-maps-in.html

  • rajeev

    thank you

  • sumandeep handa

    hlo sir i have an error when i play an app in my device google map doesn’t show i’d add also bt m facing that problemplz help me

  • AxelF

    Hi, First of thanks for the tutorial 🙂 I was wondering if you know how to send location search from a main activity and open it in the maps activity? ex. I want to search for Bowling on google maps, and send this request from the main activity when opening the maps activity using Intent.

  • Andrew Azlan Dati

    nice tutor!!!

  • Snehasis Maity

    I got the issue in Logcat::: 08-31 15:54:23.895: E/AndroidRuntime(32271): Caused by: java.lang.IllegalStateException: The meta-data tag in your app’s AndroidManifest.xml does not have the right value. Expected 7895000 but found 0. You must have the following declaration within the element:

    I added the under tag, and it works superbly.

    • Arnab Ghosal

      great i was fcing the same…thanks a lot for ur guidnce….thank u boss

  • Ankit Tale

    Does this code work on Android Studio 1.4,because it doesn’t accepting
    android:name=”com.google.android.gms.maps.MapFragment” and
    also not importing GoogleMap

  • Lalit Jadav

    hey I am not able to export app it takes long time end then return error 1

  • suren

    i cant able to show markers in android 4.1.2.. please help me

  • Murad Iqbal

    Hi, I followed your steps and those correction written in comments but I am getting the following error ‘Binary XML file line #6: Error inflating class fragment’. Any help will be greatly appreciated.

    11-21 14:55:19.660: E/AndroidRuntime(774): FATAL EXCEPTION: main

    11-21 14:55:19.660: E/AndroidRuntime(774): Process: com.example.locateme, PID: 774

    11-21 14:55:19.660: E/AndroidRuntime(774): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.locateme/com.example.locateme.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread.access$800(ActivityThread.java:135)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.os.Handler.dispatchMessage(Handler.java:102)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.os.Looper.loop(Looper.java:136)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread.main(ActivityThread.java:5001)

    11-21 14:55:19.660: E/AndroidRuntime(774): at java.lang.reflect.Method.invokeNative(Native Method)

    11-21 14:55:19.660: E/AndroidRuntime(774): at java.lang.reflect.Method.invoke(Method.java:515)

    11-21 14:55:19.660: E/AndroidRuntime(774): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)

    11-21 14:55:19.660: E/AndroidRuntime(774): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)

    11-21 14:55:19.660: E/AndroidRuntime(774): at dalvik.system.NativeStart.main(Native Method)

    11-21 14:55:19.660: E/AndroidRuntime(774): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)

    11-21 14:55:19.660: E/AndroidRuntime(774): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.Activity.setContentView(Activity.java:1929)

    11-21 14:55:19.660: E/AndroidRuntime(774): at com.example.locateme.MainActivity.onCreate(MainActivity.java:23)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.Activity.performCreate(Activity.java:5231)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)

    11-21 14:55:19.660: E/AndroidRuntime(774): … 11 more

    11-21 14:55:19.660: E/AndroidRuntime(774): Caused by: java.lang.IllegalArgumentException: Binary XML file line #6: Duplicate id 0x7f070020, tag null, or parent id 0xffffffff with another fragment for com.google.android.gms.maps.MapFragment

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.app.Activity.onCreateView(Activity.java:4791)

    11-21 14:55:19.660: E/AndroidRuntime(774): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)

    11-21 14:55:19.660: E/AndroidRuntime(774): … 21 more

  • Govind

    my xml file says rendering problems.which theme should i use or what should i do … please help
    below is my logcat error ..

    11-25 10:59:39.686 10241-10241/info.androidhive.loginandregistration E/AndroidRuntime﹕ FATAL EXCEPTION: main

    Process: info.androidhive.loginandregistration, PID: 10241

    java.lang.NoClassDefFoundError: info/androidhive/loginandregistration/PlacesMapActivity

    at info.androidhive.loginandregistration.Nearby$1.onClick(Nearby.java:127)

    at android.view.View.performClick(View.java:4461)

    at android.view.View$PerformClick.run(View.java:18525)

    at android.os.Handler.handleCallback(Handler.java:733)

    at android.os.Handler.dispatchMessage(Handler.java:95)

    at android.os.Looper.loop(Looper.java:136)

    at android.app.ActivityThread.main(ActivityThread.java:5118)

    at java.lang.reflect.Method.invokeNative(Native Method)

    at java.lang.reflect.Method.invoke(Method.java:515)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)

    at dalvik.system.NativeStart.main(Native Method)

    Caused by: java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

    at dalvik.system.DexFile.defineClassNative(Native Method)

    at dalvik.system.DexFile.defineClass(DexFile.java:222)

    at dalvik.system.DexFile.loadClassBinaryName(DexFile.java:215)

    at dalvik.system.DexPathList.findClass(DexPathList.java:322)

    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:54)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)

    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)

    at info.androidhive.loginandregistration.Nearby$1.onClick(Nearby.java:127)

    at android.view.View.performClick(View.java:4461)

    at android.view.View$PerformClick.run(View.java:18525)

    at android.os.Handler.handleCallback(Handler.java:733)

    at android.os.Handler.dispatchMessage(Handler.java:95)

    at android.os.Looper.loop(Looper.java:136)

    at android.app.ActivityThread.main(ActivityThread.java:5118)

    at java.lang.reflect.Method.invokeNative(Native Method)

    at java.lang.reflect.Method.invoke(Method.java:515)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)

    at dalvik.system.NativeStart.main(Native Method)

  • Khuloud Al Ghaithi

    I got an error in ((MapFragment) getFragmentManager()

    .findFragmentById.R.id.map)).getMap(); it said that MapFragment cannot be resolved to a type

  • Ragupathy M

    HI,

    Im getting strange error, With external storage(sd card) map view loading and working fine and if i remove sd card and open working fine. but when i uninstall and removed sd card and i run the app im getting following error, but if i put sd card and restart the mobile and open the app its working fine.. it happens after updating my device kernel version 3.1.57-g98a2f20.

    main error is: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.io.File.mkdir()’ on a null object reference

    Logcat:

    Caused by: android.view.InflateException: Binary XML file line #25: Error inflating class fragment

    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)

    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)

    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)

    at android.app.Activity.setContentView(Activity.java:2172)

    at net.blowhorn.driverapp.activity.BookingActivity_New.onCreate(BookingActivity_New.java:246)

    at android.app.Activity.performCreate(Activity.java:6251)

    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)

    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

    at android.app.ActivityThread.-wrap11(ActivityThread.java)

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)

    at android.os.Handler.dispatchMessage(Handler.java:102)

    at android.os.Looper.loop(Looper.java:148)

    at android.app.ActivityThread.main(ActivityThread.java:5417)

    at java.lang.reflect.Method.invoke(Native Method)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method ‘boolean java.io.File.mkdir()’ on a null object reference

    at com.google.maps.api.android.lib6.gmm6.m.ad.a(Unknown Source)

    at com.google.maps.api.android.lib6.gmm6.c.h.a(Unknown Source)

    at com.google.maps.api.android.lib6.gmm6.c.y.a(Unknown Source)

    at com.google.maps.api.android.lib6.e.bd.a(Unknown Source)

    at com.google.maps.api.android.lib6.e.ev.a(Unknown Source)

    at com.google.maps.api.android.lib6.e.z.a(Unknown Source)

    at com.google.maps.api.android.lib6.e.y.a(Unknown Source)

    at com.google.android.gms.maps.internal.u.onTransact(SourceFile:107)

    at android.os.Binder.transact(Binder.java:387)

    at com.google.android.gms.maps.internal.IMapFragmentDelegate$zza$zza.onCreateView(Unknown Source)

    at com.google.android.gms.maps.SupportMapFragment$zza.onCreateView(Unknown Source)

    at com.google.android.gms.dynamic.zza$4.zzb(Unknown Source)

    at com.google.android.gms.dynamic.zza.zza(Unknown Source)

    at com.google.android.gms.dynamic.zza.onCreateView(Unknown Source)

    at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)

    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)

    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:924)

    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1116)

    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1218)

    at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2170)

    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:300)

    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:748)

    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)

    at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)

    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:423)

    at android.view.LayoutInflater.inflate(LayoutInflater.java:374)

    at com.android.internal.policy.PhoneWindow.setContentView(PhoneWindow.java:393)

    at android.app.Activity.setContentView(Activity.java:2172)

    at net.blowhorn.driverapp.activity.BookingActivity_New.onCreate(BookingActivity_New.java:246)

    at android.app.Activity.performCreate(Activity.java:6251)

    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)

    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)

    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

    at android.app.ActivityThread.-wrap11(ActivityThread.java)

    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)

    at android.os.Handler.dispatchMessage(Handler.java:102)

    at android.os.Looper.loop(Looper.java:148)

    at android.app.ActivityThread.main(ActivityThread.java:5417)

    at java.lang.reflect.Method.invoke(Native Method)

    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java

  • iyan zulfayandi

    any body pls help me..
    this is the logcat

    12-14 05:19:16.722: E/AndroidRuntime(1838): FATAL EXCEPTION: main

    12-14 05:19:16.722: E/AndroidRuntime(1838): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kampoeng/com.kampoeng.MapDetail}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread.access$600(ActivityThread.java:141)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.os.Handler.dispatchMessage(Handler.java:99)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.os.Looper.loop(Looper.java:137)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread.main(ActivityThread.java:5103)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at java.lang.reflect.Method.invokeNative(Native Method)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at java.lang.reflect.Method.invoke(Method.java:525)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at dalvik.system.NativeStart.main(Native Method)

    12-14 05:19:16.722: E/AndroidRuntime(1838): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.inflate(LayoutInflater.java:492)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Activity.setContentView(Activity.java:1895)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at com.kampoeng.MapDetail.onCreate(MapDetail.java:18)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Activity.performCreate(Activity.java:5133)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)

    12-14 05:19:16.722: E/AndroidRuntime(1838): … 11 more

    12-14 05:19:16.722: E/AndroidRuntime(1838): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.MapFragment: make sure class name exists, is public, and has an empty constructor that is public

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Fragment.instantiate(Fragment.java:592)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Fragment.instantiate(Fragment.java:560)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Activity.onCreateView(Activity.java:4738)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:689)

    12-14 05:19:16.722: E/AndroidRuntime(1838): … 21 more

    12-14 05:19:16.722: E/AndroidRuntime(1838): Caused by: java.lang.ClassNotFoundException: Didn’t find class “com.google.android.gms.maps.MapFragment” on path: DexPathList[[zip file “/data/app/com.kampoeng-1.apk”],nativeLibraryDirectories=[/data/app-lib/com.kampoeng-1, /system/lib]]

    12-14 05:19:16.722: E/AndroidRuntime(1838): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

    12-14 05:19:16.722: E/AndroidRuntime(1838): at android.app.Fragment.instantiate(Fragment.java:582)

    12-14 05:19:16.722: E/AndroidRuntime(1838): … 24 more

  • Samath

    Dear sir, I can not import in into android studio, It show error message “Library reference ..google-play-services_lib could not be found”, could you help me please.

    • harin kaklotar

      means you have to add dependency in your gradle like below

      dependencies {
      compile ‘com.google.android.gms:play-services:8.4.0’
      }
      here i use latest google play services in my sdk.

  • Akhilesh Prajapati

    Thanks for such a nice tutorial.
    Please post a tutorial for draw route between two location.

  • Subin Babu

    Great Tutorial

  • Christopher Ray Lapig

    Hello Ravi, is it possible to load coordinates from database? I mean load multiple marker by getting the LatLang from database? I need a sample code badly. Thank you and Godbless Master Ravi.

    • You need a small rest api which generates a json with all the coordinates. From the app, access the url and fetch the coordinates. From here you can proceed the with same steps explained in the article.

      Have a look at below article which makes a http call to fetch the json
      http://www.androidhive.info/2015/05/android-swipe-down-to-refresh-listview-tutorial/

      • Christopher Ray Lapig

        I have a code that gets data from database, my problem is that I don’t know how to set Longitude and Latitude from database to marker. I mean if I add a new LatLong from database, it will automatically display a marker on that LatLong. I badly need it for my thesis project. 🙁 Can you create a simple code for that equation so that I can try it? Please Sir. Thank you and Godbless.

        • Give me your code where you fetch the lang, lat from the database.

          • Christopher Ray Lapig

            I am not yet fetching the lang,lat from the database Mr.Ravi, I don’t know how to insert it to the marker by Arrays. I’m just a newbie Programmer Sir. 🙁

          • Okay. Tell me what you have achieved until now. I can help from there.

          • Christopher Ray Lapig

            I have to Activity, the MapActivity and ListActivity. I am able to get data on my database using JSONParser, and post it to ListView. My problem is that I dont know how to create arrays so that I can get the LatLong from database and post it to the MapActivity.

  • Ajit

    hello ravi. please tell me how can i update the position onLocationChanged() if there are more than 1 marker at different position.. please help me.

  • Subin Babu

    show path between two location on google map ?

  • Rick

    Hey Ravi Tamada
    I’m new to Android and using your blog for learning purpose. You’re doing a great job and I’ve implemented this GoogleMap using this tutorial.
    But I don’t understand one thing, you used these 2 permissions in your Manifest file:

    Can you tell me what exactly these are? And why do we need to use it? Is it necessary?
    Thanks in advance. Cheers 🙂

  • Macharia

    I followed this tutorial and I am getting this rendering problems ,can any one help me sort it,I have tried picking the layout and haven’t found any worth help online ….,

    A tag allows a layout to dynamically include different layouts at run time..,At layout editing time the specific layout to be used is not known..,You can choose which layout to be previewed while editing the layout…..,

  • WeekendCoder

    Hi Ravi, another great tutorial, easy to follow for a beginner like me. Looking forward to the next one. 🙂
    Do you have plans on making sqlite/server tutorial that would save markers and info about locations that user can create?

  • Omar Sroujieh

    Hi Ravi i followed this tutorial and I’m trying to plot multiple markers on the map with different colour for each marker and I’m using the “BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_ROSE)” and changing the hue value every time i plot a marker, in the beginning it worked then after running it few times i it started crashing and giving me this error
    “03-05 06:40:00.064 2076-2076/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.osroujieh.policedataapi, PID: 2076
    java.lang.OutOfMemoryError: [memory exhausted] at dalvik.system.NativeStart.main(Native Method)”
    I’ve been stuck on this for quiet while i can seem to find an answer, i was hoping if you would be able to help.

    thanks 🙂

  • Mario German Agudelo

    as I can get the coordinates of MySQL different places? I appreciate all your help

  • Mehul Gajjar

    hi i followed your tutorial its working perfectly but

    i am working with 2 languages english and arabic i want to display map as per user language selection.

    i am getting issue when i select arabic language and update language but google map is not change in arabic but when i remove app from recent app and then again open it then it will update google map into arabic. by getting value from shared-preference.

    i am using this code

    String templng = myPrefrence.getStringReponse(Config.LANGUAGE);
    if(templng.equals(“en-us”))
    {
    String languageToLoad = “en-us”; // your language
    Locale locale = new Locale(languageToLoad);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getActivity().getApplicationContext().getResources().updateConfiguration(config,
    getActivity().getApplicationContext().getResources().getDisplayMetrics());
    }
    else
    {
    String languageToLoad = “ar”; // your language
    Locale locale = new Locale(languageToLoad);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getActivity().getApplicationContext().getResources().updateConfiguration(config,
    getActivity().getApplicationContext().getResources().getDisplayMetrics());
    }

  • Manivel.m

    Hai Ravi sir google map integration in androidhive using android studio

  • carole

    Hello .how can read Latitude and longitude from a gpsDatabase I have created and plot it on Google map(offline option)
    thank you

  • crazyfool

    Hi Guys, my app with this code is not running under KitKat android version.. do you know something about it?

  • Muhammad Salma Nabila Alibasyi

    Hi Ravi, nice tutorial. I wanna make app like it but it uses gps data from mysql database to show marker on android map. Can you give tutorial like this?

    • Edo Firmansyah

      wis lulus kok njaluk warah

  • Mohit Khaitan

    Hi Ravi, I am showing the map in a fragment and every time the fragment is re-created the map also gets recreated. I have a static marker and on recreating it animates to the marker. I want to load the map only once at the time of the creation. What should I do ?

  • prasanth s

    hi ,
    i need to customize my map. can u tell me how to draw routes between fixed one marker to custom search box address.

  • Rahul Kumar

    Hey I downloaded your source code and then also it is showing error that
    Authorization failure.
    Ensure that the “Google Maps Android API v2” is enabled.
    Ensure that the following Android Key exists:
    API Key: AIzaSyBK8rKr9lCRLhzv68I4Q26G9pHHOiWqO40

    • Sharkes Monken

      Try get your own API key instead

  • akhil mb

    how to store and retrieve location data from sqlite ?????

  • Jayakumar

    Hi Can we get any updated article on handling map in Android N.
    Thank you!

  • Shaikh aziz

    my project is to add a location as your destination and when you reach that destination you will get a notification in the form of broadcast .

    • Daksh Gargas

      This doesn’t seem to be a very big problem, have you fixed it?

  • Gaurish Abhisheki

    How to save maps for offline retieval

  • chandra teja

    hi ravi sir I am waiting for finger print code
    please send it sir
    thank you giving me reply in advance

  • Deepak Kanyan

    hi ……..Please update with latest code….

  • vinsen

    i try it no eror
    but when i run it
    it suddenly forceclosed

    • Shamima Nasrin Shanta

      add permissions in user android manifest

  • Parth M. Ravrani

    i want to predefine a specific location so that every time when a user opens my app it redirects to that location…
    Is that Possible…

  • rama

    hello ravi,
    Under step 1 after doing
    Eclipse ⇒ Windows ⇒ Android SDK Manager I cant see Google Play Services under Extras(Folder)

    • Hi Rama

      You have to use Android Studio now and the steps varies.

  • Abhishek Saxena

    hello ravi
    Can you tell me how to show direclty my current location bcoz right now it shows world map then after clicking on compass icon it redirects to my current location i want when i open my app it should show my current location ??