Integrate Google Map v2 on Android

Google Map v1 has been deprecated and its time migrate to the Google Map v2. Google Map API allow the android application use the major feature of Google Map such as Add Marker in the Google Map, track location, search location and more. Integrate the google map api into your android app is good for showing your business location or implement some taxi app such as uber. In this tutorial, I will teach you on how to integrate google map v2 on android application so that you able to use it.

Create a Project in Google Console

Now, go to the google console to create a new google console project for your android application.


Generate Google Map API Key

Open your command prompt and use java keytool to generate SHA-1 fingerprint. You can following the example command line in the below.

For Windows

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

For Mac OS X or Linux

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



Enable Google Map Android API and Create a Credential for Android API Key

Find the Google Map Android API and enable it, after that create a android api key for your project. Add package name and SHA-1 fingerprint to restrict usage to your android app.


After create the credential, you will get your Android API Key.


Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “GoogleMapApiExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Install Google Play Services SDK

Launch your SDK manager in the android studio and download the Google Play Services SDK as the image show below.


Add new Dependency

Go to build.gradle (Module:app) and add the following code to your dependency section.

Add google_maps_api.xml

Create a xml file and name it as “google_maps_api.xml” in your res > values folder. After create the file, copy the source code and insert the android api key.

Edit AndroidManifest.xml

Add new permission and feature in the manifest file so it can work well later. After that, also add the meta-data it able to get your api key.

Edit activity_main.xml

Go to your activity_main.xml and add the google map fragment inside your layout so it able to show the map later.

Edit class

Go to class and paste the following source code, the following source code able to get your current location and also add marker to the map. You can customize later.

Run your project

Finally, you can run the google map in your android device.

Note : if you are using emulator to run this project may cause the error because your emulator dont have google services, google map and google play.

(Integrate Google Map v2 on Android)

Source Code

(Visited 456 times, 1 visits today)

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *