Setting Up an Existing Android Studio Project

This page describes how to configure an Android Studio project to use the Maps SDK for Android without using the Google Maps template that is detailed in the Quickstart.

The Google Maps template automatically configures and adds a basic map to a new Android Studio project. However, you can also add a map to an Android project that uses a different Android Studio template. To do so, you need to manually configure your project and then add the map.

Set up Android Studio

  1. Android Studio is required. If you haven't already done so, download and install it.

  2. Add the Google Play services SDK to Android Studio. The Maps SDK for Android is distributed as part of the Google Play services SDK, which you can add through the SDK Manager.

Set up a Cloud project and API key

To set up a Cloud project and API key:

Update the app manifest

This section describes the settings to add to your AndroidManifest.xml file.

Google Play services version number

Add the following declaration within the application element. This embeds the version of Google Play services that the app was compiled with.

    android:value="@integer/google_play_services_version" />

Location permission

If your app needs to access the user's location, you need to request the location permission in your AndroidManifest.xml file. The options are ACCESS_FINE_LOCATION, which provides the precise user location, and ACCESS_COARSE_LOCATION, which is less precise. For details, see the location data guide.

To request the ACCESS_FINE_LOCATION permission, add this code to the manifest element:

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

External storage permission

If you're targeting version 8.3 or later of the Google Play services SDK, you don't need the WRITE_EXTERNAL_STORAGE permission. If you're targeting earlier versions of the Google Play services SDK, you must request the WRITE_EXTERNAL_STORAGE permission, in the manifest element.

        android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

Apache HTTP Legacy library

If you are using or below and your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the <application> element of AndroidManifest.xml. Otherwise, skip this declaration.

    android:required="false" />

Add the Maps dependency

In your app-level build.gradle file, add the Maps dependency. For details, see the versioning guide.

dependencies {
    implementation ''
    // ...

Next steps

Once your project is configured, you can add a map.