Android Migrate Google Play Places (Deprecation) to Places SDK

Notice: The Google Play Services version of the Places SDK for Android (in Google Play Services 16.0.0) is deprecated as of January 29, 2019, and will be turned off on July 29, 2019. A new version of the Places SDK for Android is now available. We recommend updating to the new version as soon as possible. For details, see the migration guide. - Source

The new version of the Places SDK for Android is distributed as a static client library. Until now, the Places SDK for Android has been made available through Google Play Services.

NOTE: I was using

Migration Path

Basically, there are 2 migration path

Compatibility Library

I choose the compatibility library path I want to solve the problem as fast as possible without further complication (the project is not actively being developed).

For dependecies, remove and add

dependencies {
    // implementation ''
    implementation ''

Replace packages references. Change




Change Powered by Google assets.

@drawable/powered_by_google_light // OLD
@drawable/places_powered_by_google_light // NEW

@drawable/powered_by_google_dark // OLD
@drawable/places_powered_by_google_dark // NEW

NOTE: minSdkVersion need to be 16 or higher.

NOTE: There is a compatibility script but I didn't use it as I am running on Windows.

Code Updates

Code changes required

  • PendingResult is no longer supported, need to switch to Task instead.
  • Places.PlaceDetectionApi -> Places.getPlaceDetectionClient(context)
  • Places.GeoDataApi -> Places.getGeoDataClient(context)

Sample code: getCurrentPlace

Old code

PendingResult<PlaceLikelihoodBuffer> result = Places.PlaceDetectionApi                .getCurrentPlace(googleApiClient, null);PlaceLikelihoodBuffer likelyPlaces = result.await();

New code

PlaceDetectionClient placeDetectionClient = Places.getPlaceDetectionClient(context);Task<PlaceLikelihoodBufferResponse> result = placeDetectionClient.getCurrentPlace(null);PlaceLikelihoodBufferResponse likelyPlaces = Tasks.await(result);

Sample code: getPlaceById

Old code

PendingResult<PlaceBuffer> placeResults = Places.GeoDataApi.getPlaceById(googleApiClient, placeIds);PlaceBuffer placeBuffer = placeResults.await();

New code

GeoDataClient geoDataClient = Places.getGeoDataClient(context);Task<PlaceBufferResponse> placeResults = geoDataClient.getPlaceById(placeIds);PlaceBuffer placeBuffer = Tasks.await(placeResults);

Sample code: getAutocompletePredictions

Old code

if (googleApiClient.isConnected()) {    PendingResult<AutocompletePredictionBuffer> results =            Places.GeoDataApi.getAutocompletePredictions(googleApiClient, query,                    bounds, placeFilter);    final Status status = autocompletePredictions.getStatus();    if (!status.isSuccess()) {    }}

New code

Task<AutocompletePredictionBufferResponse> results = geoDataClient.getAutocompletePredictions(query, bounds, placeFilter);AutocompletePredictionBufferResponse autocompletePredictions = Tasks.await(results);

Places SDK Compatibility Libraries Caveats

The compatibility libraries didn't support Session Tokens used by findAutocompletePredictions which helps to reduce cost.

NOTE: Refer Google Place Autocomplete Pricing

It also didn't support Field masks or Place Data Fields which could help to reduce cost based on what type of data is required.

NOTE: Refer Google Place Details Pricing.

Places SDK Compatibility Libraries might not be a good solution if you are worry about cost and your app have high usage.


❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.