Get Started

To configure your app to use the Places SDK for Android, follow these steps. They are required for all apps using the Places SDK for Android.

Prior to using the Places SDK for Android, do the following:

Step 1. Install the SDK

The Places SDK for Android library is available through Google's Maven repository. To add the SDK to your app, do the following:

  1. In the buildscript.repositories section of your top-level build.gradle file, make sure Google's Maven repo is listed:

    buildscript {
        repositories {
            google()
            // ...
        }
    }
  2. In the dependencies section of your app-level build.gradle file, add a dependency to the Places SDK for Android:

    dependencies {
      implementation 'com.google.android.libraries.places:places:2.0.0'
    }

Step 2. Initialize the Places API client

Initialize the Places SDK for Android, as shown in the following example (note that you pass the API key when calling Places.initialize()):

// Initialize the SDK
Places.initialize(getApplicationContext(), apiKey);

// Create a new Places client instance
PlacesClient placesClient = Places.createClient(this);

You are now ready to begin using the Places SDK for Android!

Enviar comentários sobre…