Android Studio: add Google Map from empty activity (dev note)

//Update: I prepared a simple Android app that features a Google Map with markers that form clusters together when zoomed out. Check it out: Simple Android Map Clustering on GitHub.

This “dev note” of mine will give you a rough idea on how to add a Google Map to your Android up from an empty activity, not from a pre-made Google Maps activity.

I won’t be able to write everything in detail here because I’m in a hurry, and so I’m calling this article a “dev note” instead of tutorial. 🙂 This dev note can be considered a “guide” too.

This dev note was based on Android Studio v.2.1 running on MAC OS X

From your Android Studio’s SDK Manager, install Google Play Services.

Add this as child of <application> tag in AndroidManifest.xml:

Later we’ll replace YOUR_API_KEY with a key from Google API Console.

Also add these to your AndroidManifest.xml as direct child of manifest tag:

We need to get an API KEY for the value attribute of this meta data. Let’s get one from the Google API Console — create a new project there and then search for Google Maps Android API. Enable it.

After enabling it, you’ll find a way to get an API key that we need from Google API Console. Go to Credentials -> Create Credentials -> API Key -> Android Key. Before we are given the API key, we need to provide Google API Console a SHA1 certificate fingerprint from our computer and our app’s package name.

To generate SHA1 certificate fingerprint on a Mac, type this on the terminal:

On Windows, try this command:

When prompted for a keystore password, enter the word debug as your password.

Copy the SHA1 certificate fingerprint and then paste it into Google API Console. Enter your package name as well (e.g. com.yourdomain.projname). You’ll be given an API Key in return.

Note: My Android Studio says ‘In the Google Developer Console (, ensure that the “Google Maps Android API v2” is enabled.’ but I can’t find the option for V2.

Remember the meta-data tag we added in the AndroidManifest.xml? Replace the value with the API key that you just copied from Google API Console.


Open app/build.gradle file and add the following as dependency:

Sync your project with Gradle files.

This was one of the tutorials I followed: GOOGLE MAPS ANDROID API V2 TUTORIAL USING ANDROID STUDIO and I based my XML plus Java codes on the author’s.

My files in the end…

Here were the codes of my Android app when I finally made the Google Map show up in the activity:






…even though the Google Map now shows up on my Android activity, I get these errors that I’m not able to fix yet:

Related Posts:

Posts that may be related to "Android Studio: add Google Map from empty activity (dev note)":


A Filipino programmer with a variety of interests such as baking, singing, making up silly song/rap lyrics, K-pop, drawing, creating unique dessert flavors, obsessing about finding out how some things works, board games, anime, video games, and forgetting things that usually go in her long list of interests. Running small-time online dessert shops Cookies PH and Catzie's Cakery.

Leave a Reply

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