Android Google Maps API Usage

I will use the Google Maps API, which is common in Android applications.

You can do many things on the maps you have added to your applications. It is necessary to use the Maps API for many ideas, such as location tracking, building street illustrations, seeing places nearby.

You can download and use Yandex or OSM (Open Street Map) SDKs outside the Google map, but my preference for source and functionality is Google Maps.

Add Google Map to the Project

We will talk about what to do step by step:

  • Create a project in Developer Console
  • Enable Google Maps API
  • Get API Key
  • Learn fingerprint and add console
  • Create an Android Studio project
  • Google Play Services update
  • Update AndroidManifest.xml and Build.gradle file

Creating a Project in Developer Console

Let’s go ahead and create a project like this

Enter the project name as above and hit the create button

Enable Google Maps API

We have created the project. Now enable the Google Maps API. To do this, click APIs and Services -> Bookshelf from the menu on the left in the same screen.

Let’s click on the Google Maps Android API entry and the result will come to the area of the simulated incoming.

Activate the Google Maps API by clicking the Enable button after clicking it.

Get API Key

After the project has been created, click APIs and Services -> ID information button on the left menu and click Generate credentials -> API key.

An API Key will be given to us after we click on it. You’ll have to add it to the console and Android studio project that you’ll see soon.

We got the API key. By clicking on the Restrict Key button, we will only have to restrict our project to access this API. Because the Google Maps API has a usage quota, and those who acquire the API Key can consume the quota using the API in their own applications.

Learn Fingerprint and Add Console

Now we can restrict the key so that we can prevent someone else from using it. We will need to add line-by-line with our application’s Package Name and fingerprint information. I’ve added the final version below. We should choose  Application Restrictions as Android Apps. At the bottom we have to add a new line for each computer we work with. I’ve added SHA-1 certification for this computer. If you want to work in another project with the same API Key, you need to add another package name and the same SHA-1 certificate.

Where do we learn the SHA-1 certificate, Fingerprint?

After creating the project in Android Studio, open the Gradle panel on the right as below and come up to the signingReport button and double click on it. Once you click on it, it will give you SHA-1. You can copy and paste it.

If you can not get an output like the following visual, press the blue circle button

You can copy this value and paste the key constraint division.

Your applicationId in package name gradle.

Step by step to Create a Android Studio Project

  • I have created a map activity project directly and you can create it in a blank project

Google Play Services Update

The project has been created but you need to install Google Play Services or update the latest version to use Google Maps.

From the top menu, click Tools -> Android -> SDK Manager to open the SDK Installation window.

If it needs to be updated, it will be in a white box with a line, click on it and go to Apply and complete the update.

Edit AndroidManifest.xml and Build.Gradle File

To use the Google Maps API, I’ll add the following line to the dependencies section of the build.gradle file.

  • File:Gradle Scripts/build.gradle(Module:app)

Do not forget to sync now after adding

We’ll add here the API_KEY value we get.

  • File:app/manifest/AndroidManifest.xml

We added 2 meta-data values. One has API_KEY value and the other is Google version. The version is not mandatory, but I added it anyway.

Finally we will write our code in MainActivity class in the code part.

Start Coding

First, we are adding a FRAGMENT to the activity_main.xml file.

  • File:res/layout/activity_maps.xml (it does not matter that you can name it activity_main.xml)

  • File:app/MapsActivity (it does not matter that you can name it MainActivity)

In our file we have defined a simple map and added 1 marker.



if you have question do not forget to write from the chat button next to it or from the comment


You may also like...

11 Responses

  1. Eric Balloon says:

    thanks for sharing this information.

  2. thanks for sharing this information have shared this link with others keep posting such information..

  3. Lindsey Albarazi says:

    thanks for sharing this information.have shared this link with others keep posting such information..

  4. Margery Walley says:

    thanks for sharing this information.

  5. thanks for sharing this information.have shared this link with others keep posting such information..

  6. Roseanne says:

    Page as a most excellent website for most up-to-date updates.

  7. oliverjarman says:

    Thanks for another excellent article.

  8. Norah says:

    It’s remarkable designed for me to have a site,
    which is valuable in favor of my knowledge. thanks admin <3

  9. Susanne says:

    In the end I got a webpage from where I be capable
    of truly take useful information concerning my study and knowledge.thx

Leave a Reply

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