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.

If you haven't already obtained an API key and enabled the Places API, follow the instructions in the Get API Key and Signup guide to get one now.

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:1.0.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 14 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!

フィードバックを送信...