Places Android KTX Overview and Setup

Places Android KTX is a collection of Kotlin extensions for the Places SDK for Android. These extensions provide Kotlin language features that enable you to write concise and idiomatic Kotlin when developing for the Places SDK for Android. Places KTX is open-sourced and available on GitHub along with examples.

Install KTX for the Places SDK

To install KTX for the Places SDK for Android, add the following dependencies to your app-level build.gradle file.

dependencies {
    implementation 'com.google.places.android:places-ktx:0.2.2'
}

If you are using the Places static library with Maps SDK V3 BETA, add the following dependency to your app-level build.gradle file instead.

dependencies {
    implementation 'com.google.places.android:places-v3-ktx:0.2.2'
}

Try the sample application

The GitHub repository for this library also contains a demo application that shows how you can use the Places KTX library in your own app.

First screen of the Places KTX sample app, showing your choices
Places Search Demo app screen

To try the demo application, follow these steps:

  1. From GitHub, clone the or download the ZIP file.
  2. In Android Studio, choose File -> Open and navigate to the directory and open the folder that you just cloned or downloaded.
  3. Add an API key to the demo app.
    1. Get a Places API key.
    2. In the root directory, create a file called secure.properties. This file should NOT be under version control to protect your API key.
    3. Add this single line to secure.properties
      PLACES_API_KEY=”YOUR_API_KEY”
      where YOUR_API_KEY is the actual API key you obtained in the first step. You can look at the secure.properties.template as an example.
  4. Under the run configuration, select the module app.
  5. Select Run ‘app’.