Integrating Google Maps in Android App

Integrating Google Maps in Android App using Android Studio


In this blog post I will explain how you can integrate Google Maps in your Android project. Follow the below steps:


1. Add the Google Play services package to Android Studio.

2. Create Android Studio Google Map Project. For Creating Android Studio Project follows these given steps:

  • Follow these steps to create a new app project including a map activity:
  • Start Android Studio.
  • Create a new project as follows:
  • If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under ‘Quick Start’ on the right of the dialog.
  • Otherwise, click File in the Android Studio menu bar, then NewNew Project.
  • Enter your app name, company domain, and project location, as prompted. Then click Next.
  • Select the form factors you need for your app. If you’re not sure what you need, just select Phone and Tablet. Then click Next.
  • Select Google Maps Activity in the ‘Add an activity to Mobile’ dialog. Then click Next.
  • Enter the activity name, layout name and title as prompted. The default values are fine. Then click Finish.


Now Android Studio will start gradle and build your project. This may take a few of second to build your project. When the build is finished then Android Studio will opens the google_maps_api.xml and files in the Editor.(Activity name can have different name but it will be only what name you are given in setup wizard).


3. How to Google Maps API Key: Now your application will require an API key to access the Google Map servers. This key is free and you can use this key in your any of Google map api project. You can get Google Maps API key in following steps.


  1. Open the Google Developer Console.
  2. Follow the instructions to create a new project on the console. If you have already created an API project you can select that.
  3. Create an Android API key for your console project. You can create API key by using as given steps:       

           a. Click on Credential, It will list out all your created credential and Create credential option.

           b. Choose Create Credential option, when you click on Create credential it will prompt to select                API key option from given options.
           c. When you click on API key, it will further prompt you for choose appropriate option.
           d. Choose Android key option in given prompt dialog.
           e. As soon as you click on Android key it will ask you the package name of project and sh1 key                of your pc that is created from you keystore file with signed or debug keystore file.
               You can get SH1 key by using given command from command prompt or terminal.
                keytool -list -v -keystore mystore.keystore

       4. Copy the resulting API key, go back to Android Studio, and paste the API key into the <string> element in the xml file.

      Note: For using the service of Google Map into you Android project you must have enabled the Google Map Api from Google API Console page. Your app will not be able to access Google Map until you did not enabled the Google Map API for Android.


      5. Now take a look at the Code.


  • XML layout file(activity_map) will be look as follows.
       <fragment xmlns:android=””
  • The Map Activity java file( : By default it takes file name. It should contain the following code after your package name:
       import android.os.Bundle;


public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {


private GoogleMap mMap;

protected void onCreate(Bundle savedInstanceState) {
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()


public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;


// Add a marker in Sydney, Australia, and move the camera.
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title(“Marker in Sydney”));


If in any case your .java file does not contain above code the you can replace your code with above of the  code in Your file.


       6. Manifest File(permissions needed for your app)


Manifest file contains all the information about your app. In manifest file you must have to declared following part of code. Manifest file should contain following permission.

<uses-permission android:name=“android.permission.ACCESS_FINE_LOCATION” /> 

Manifest file should contain information about your google map api key and google play services version in MetaData like as follows: 

android:value=“@integer/google_play_services_version” />                               
android:value=“@string/google_maps_key” />


       7. Connect an Android device


Best way to see your app in action is Run your app in Android device. You can also use Android Emulator as alternate of it. Your android phone should have developer option enabled.


        8. Build and Run your app


In Android Studio you can run your app by using Run menu option. You can also use play button icon to Run your app. When you play or run your app it will prompt you to select device. You can choose one of the following option:

  • Select your Android phone that you have connected with Computer or
  • You can select Android Emulator radio button and choose available or created virtual Android emulator.
  • Click on Ok, Android Studio will start gradle to build your app and display to corresponding results on a device or in Emulator. It can take couple of minute before open the app. You should able to see corresponding result on Google map with a pin.


 Still facing any issue with Google Maps? Or want to be in touch with us? Contact us at




Triffort Technologies Pvt Ltd



Posted in Android | Tagged androidgoogle mapsgoogle studiomaps


thank you for the article ...but in my case google maps activity option does not cone in current project.. If I create new project and follow the steps , it works , but if i am trying to add google maps ..then I can not !!!

Thanks for sharing a knowledgeable article for android apps development

This is a good blog for developer and thanks for sharing such a good idea of android application development and it is the best way to learn our weekness. generic cialis fast delivery cialis tadalafil work

viagra from canada viagra on line with prec generic viagra safe Viagra generico online generic viagra online how to order viagra without pre buy cheap viagra in canada

canadian pharmacies shipping to usa Northwest Pharmacy best canadian mail order pharmacies canada rx online pharmacies canadian pharmacies that are legit canadian discount pharmacies in ocala fl

Cialis 20mg cialis from usa pharmacy cialis pills for sale cialis prices Cialis 20 mg can you buy viagra in mexico without a prescription http://xn--80aa1bjf.xn--p1ai/bitrix/redirect.php?event1=&event2=&event3=&goto= buy cialis online safely

canadian prescriptions online canada vagra are canadian online pharmacies safe canada rx canada online pharmacies canadian pharmacy no prescription northwest pharmacies online

cialis without a doctor's prescription in usa buy cialis no rx cialis online cialis prices walmart cialis purchase online without prescription cheap cialis without a doctors prescription

Cialis canada generic cialis tadalafil uk cialis cena cialis 5 mg side effects Best buy canada online real cialis without a doctor's prescription buy tadalafil no prescription

viagra on line viagra pills definition viagra generica pedido en espanol viagra pills 100 mg generic viagra viagra without doctor visit buy viagra with no prescription

canadian pharmacies online pharmacy canada reviews canadian drugstore canada pharmaceuticals online canadian online pharmacies buy viagra now online pharmacy canada

buy cialis with prescription buy cheap cialis in canada cialis online cialis anda litigation cialis purchase online without prescription tadalafil without prescription

Buy cialis online cialis generico online cialis online cialis 20 mg coupon Buy cialis cialis without prescriptions buy tadalafil no prescription

buy viagra viagra pills for men Viagra 5mg viagra pills at walmart viagra generic cheap viagra without script buy viagra cheap

drugstore online northwest pharmacies canadian pharmacies-24h Northwest Pharmacy online pharmacies canada candida viagra canadian medications list

cialis without a doctor's prescription in usa cialis 5 mg daily tadalafil without a doctor's prescription cialis 5 mg cialis purchase online without prescription buy cialis online without a prescription

Cialis prices cialis cena apoteka tadalafil 10 mg cialis 5 mg price walmart Cialis pills cialis without a doctor's prescription from canada buy cialis online us pharmacy

cialis without a doctor's prescription in usa cialis vs viagra buy tadalafil 20mg cialis lowest price tadalafil without a doctors prescription cialis daily use without prescription

real cialis without a doctors prescription generic for cialis buy cialis online best price tadalafil generic 20mg tadalafil without a doctor's prescription cialis without a doctors prescription in usa

cialis without prescription cialis without a doctor's prescription cialis 5 mg side effects tadalafil tablets 10mg tadalafil without a doctor's prescription cialis without doctor prescription

how to buy cialis without a prescription generic cialis tadalafil fast cialis prices 10mg buy tadalafil pills cialis no doctor's prescription can you buy cialis without a prescription

cheap cialis without prescription buy cialis cialis cena srbija cialis tadalafil 40mg can you buy viagra without prescription can you buy viagra in mexico without a prescription

Leave a reply

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




Social Comments
Go top