---
title: "Google Maps API v2 in Android"  
description: "In this article I am explaining about Google Maps API v2 in Android"  
author: "Manoj Pandey"  
published: 2015-03-13  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1661/google-maps-api-v2-in-android  
category: "android"  
tags: ["android"]  
reading_time: 3 minutes  

---

# Google Maps API v2 in Android

The Android [platform](https://www.mindstick.com/articles/13080/wikipedia-the-most-powerful-advertising-platform-of-the-digital-age) provides easy and tight [integration](https://yourviews.mindstick.com/view/88515/common-mistakes-in-computer-integration-to-avoid) between Android [applications](https://www.mindstick.com/articles/12847/how-to-choose-the-right-ethernet-cable-for-industrial-applications) and Google Maps. The well-established Google Maps APIis used under the hood in order to bring the power of Google Maps to your Android applications.\

This [tutorial](https://yourviews.mindstick.com/view/81591/semrush-tutorial-and-review-2020-how-to-use-it-to-20x-your-website-traffic) is to learn how to show the current [location](https://www.mindstick.com/news/2574/twitter-conveniently-reveals-a-location-sharing-policy-amid-elonjet-controversy) on map in an [Android application](https://www.mindstick.com/articles/1653/creating-libraries-for-android-applications) using [Google Maps API](https://www.mindstick.com/forum/600/google-maps-api-problems-with-class-glatlngbounds).

##### For use Google Map API you must be follow some steps-:

##### \

1. Install Google Play Service form SDK Manager

![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/b3fe1263-0800-4f4f-9573-7c2c0bae2a1b.png)\

**2.** Import google-play-services_lib library from C:\Eclipse\adt-bundle-windows-x86_64-20131030\adt-bundle-windows-x86_64-20131030\sdk\extras\google\google_play_services\libproject

3. Create a Google Map Key from [Google Console](https://code.google.com/apis/console/).

Before create Google Map key you have need creating the SHA-1 for your signature key.

· On Menu click Window then click Preferences

· Click Android then select Build

![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/20e91c39-1724-41f5-8919-3e7f9baeae63.png)

Now open [Google API](https://www.mindstick.com/forum/34053/how-to-use-google-api-analytics) console

Crate a new API Key

![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/907dceb6-887b-48cb-a30a-a0de3df1fb76.png)

##### Add your SHA1 fingerprints and package name

##### \

![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/d2001709-b620-4856-be0a-6aab10b1d41d.png)

##### After press Create button will be generate a key

\
![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/3aaff0ca-8f42-41a7-8a40-854df9286b9c.png)

**4**. Add permission in Manifest file

```
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"    package="com.example.androidgoogleapi"    android:versionCode="1"    android:versionName="1.0" >     <uses-sdk        android:minSdkVersion="12"        android:targetSdkVersion="18" />     <permission   android:name="com.example.androidgoogleapi.permission.MAPS_RECEIVE"        android:protectionLevel="signature" />     <uses-permission android:name="com.example.androidgoogleapi.            permission.MAPS_RECEIVE" />    <uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>    <uses-permission android:name="com.google.android.providers.gsf.       permission.READ_GSERVICES" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>     <!-- 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"        android:theme="@style/AppTheme" >        <meta-data            android:name="com.google.android.maps.v2.API_KEY"            android:value="AlzaSyCrrkL5KnBrwzHFr2svng-hFMrqPX70wIO" />        <meta-data            android:name="com.google.android.gms.version"            android:value="@integer/google_play_services_version" />         <activity            android:name="com.example.androidgoogleapi.MainActivity"            android:label="@string/app_name" >            <intent-filter>                <action android:name="android.intent.action.MAIN" />           <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>        </activity>    </application> </manifest>
```

**5.** My activity_main.xml file

```
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity" >     <fragment        android:id="@+id/map"        android:layout_width="match_parent"        android:layout_height="match_parent"        class="com.google.android.gms.maps.SupportMapFragment" /> </RelativeLayout>
```

6. Add following code in MainActivity.class

```
import android.app.Activity;import android.os.Bundle;import android.view.Menu; import com.google.android.gms.maps.CameraUpdateFactory;import com.google.android.gms.maps.GoogleMap;import com.google.android.gms.maps.MapFragment;import com.google.android.gms.maps.model.BitmapDescriptorFactory;import com.google.android.gms.maps.model.LatLng;import com.google.android.gms.maps.model.Marker;import com.google.android.gms.maps.model.MarkerOptions; public class MainActivity extends Activity {  static final LatLng HAMBURG = new LatLng(53.558, 9.927);  static final LatLng KIEL = new LatLng(53.551, 9.993);  private GoogleMap map;   @Override  protected void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    setContentView(R.layout.activity_main);    map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))        .getMap();    Marker hamburg = map.addMarker(new MarkerOptions().position(HAMBURG)        .title("Hamburg"));    Marker kiel = map.addMarker(new MarkerOptions()        .position(KIEL)        .title("Kiel")        .snippet("Kiel is cool")        .icon(BitmapDescriptorFactory            .fromResource(R.drawable.ic_launcher)));     // Move the camera instantly to hamburg with a zoom of 15.    map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));     // Zoom in, animating the camera.    map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);  }   @Override  public boolean onCreateOptionsMenu(Menu menu) {    getMenuInflater().inflate(R.menu.activity_main, menu);    return true;  }}
```

Now run your application

![Google Maps API v2 in Android](https://www.mindstick.com/mindstickarticle/c0dc25c5-1abf-4132-904b-c59771070284/images/25ae5e01-b684-4c5e-b97c-fecbe1ec3041.png)

---

Original Source: https://www.mindstick.com/articles/1661/google-maps-api-v2-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
