As a follow-up to the quick-start guide, this page describes all the configuration you need in your development project when using the Google Maps Android API in your Android app.
The overall process of adding a map to an Android application is as follows:
- Install the Android SDK.
- Install and configure the Google Play services SDK, which includes the Google Maps Android API. Note: If you use the Google Maps Android API with a Google Maps APIs Premium Plan license, you must download and configure the Premium Plan SDK instead.
- Get an API key. To do this, you will need to register a project in the Google API Console, create an API key, and restrict the API key using your app's signing certificate.
- Add the required settings to your application's manifest.
Below are more details about each step in the process.
Install the Android SDK
Android Studio is the recommended development environment for building an app with the Google Maps Android API. Guidelines are provided for other development environments too. Select the tab for your development environment.
If you prefer to use a different IDE or run the tools from the command line or with build scripts, you can instead download the stand-alone Android SDK Tools. Then add the required packages, including Google Play services as well as the other recommended packages.
Install and configure the Google Play services SDK
You need an Android project for your app, to complete the steps in this section. If you haven't yet created an Android application, you can follow the guide to creating a 'hello world' app. See Creating an Android Project.
The Google Maps Android API is distributed as part of the Google Play services SDK. You can download the Google Play services SDK via the Android SDK Manager.
For detailed instructions, see the Google Play services documentation.
Get a Google Maps API key
To use the Google Maps Android API, you must register your app project on the Google API Console and get a Google API key which you can add to your app.
For details, see the guide to getting an API key.
Add the required settings to your app's manifest
Edit your application's
AndroidManifest.xml file and add
the following settings.
Specify the Google Play services version number
Add the following declaration within the
<application> element of
AndroidManifest.xml. This embeds the version of Google Play services that the
app was compiled with.
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Specify your API key
Ensure you include your API key in the
AndroidManifest.xml file, as
described in the guide to getting an API key.
Specify Android permissions
Specify the permissions your application needs, by adding
elements as children of the
<manifest> element in
If your application accesses the user's current location by enabling the My Location layer, you must request location permissions as described in the guide to location data.
External storage permission
If you're targeting version 8.3 or later of the Google Play
services SDK, you no longer need the
WRITE_EXTERNAL_STORAGE permission to use the
Google Maps Android API.
If you're targeting earlier versions of the Google Play
services SDK, you must request the
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Note: If your app is targeting API level 23 (Android 6.0), which requires the use of runtime permissions, you should target version 8.3 or later of the Google Play services SDK.
Permissions automatically merged into your manifest
The following permissions are defined in the Google Play services manifest, and are automatically merged into your app's manifest at build time. You don't need to add them explicitly to your manifest:
android.permission.INTERNET- Used by the API to download map tiles from Google Maps servers.
android.permission.ACCESS_NETWORK_STATE- Allows the API to check the connection status in order to determine whether data can be downloaded.
Specify requirement for OpenGL ES version 2
The Google Maps Android API uses OpenGL ES version 2 to render the map. The following setting is defined in the Google Play services manifest, and is automatically merged into your app's manifest at build time. You don't need to add it explicitly to your manifest:
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
This notifies external services of the requirement. In particular, it prevents Google Play Store from displaying your app on devices that don't support OpenGL ES version 2.