Get Started

To configure your app to use the Places SDK for Android follow these procedures. The following configuration steps 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

You can use Maven to add the Places SDK for Android client library to your Android Studio project. To install the SDK client library, take the following steps:

  1. In the dependencies section of your app-level build.gradle file, add a dependency for the new SDK client library, as shown in the following example:

  2. dependencies {
      implementation 'com.google.android.libraries.places:places:1.1.0'
    }
  3. In your activity, add an import statement for the client library.

    import com.google.android.libraries.places.api.Places;
  4. Set the minSdkVersion for your application project to 16 or higher.

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():

// Add import statements for the new library.
import com.google.android.libraries.places.api.Places;
import com.google.android.libraries.places.api.net.PlacesClient;

...

// Initialize Places.
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!

发送以下问题的反馈:

此网页
Places SDK for Android