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 {

    // KTX for the Places SDK for Android library
    implementation 'com.google.maps.android:places-ktx:3.1.1'
}

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 secrets.properties. This file should NOT be under version control to protect your API key.
    3. Add this single line to secrets.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 local.defaults.properties as an example.
  4. Under the run configuration, select the module app-places-ktx.
  5. Select Run 'app-places-ktx'.