Skip to content

fix(tutorials): migrate CurrentPlaceDetailsOnMap to Places SDK 6 - #2456

Merged
dkhawk merged 1 commit into
mainfrom
fix/current-place-tutorial-places-6
Oct 15, 2026
Merged

dkhawk merged 1 commit into
mainfrom
fix/current-place-tutorial-places-6

Conversation

@kikoso

@kikoso kikoso commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

Places SDK for Android 6.0 (bumped in #2455) removed Places.initialize and PlacesClient.findCurrentPlace. Both CurrentPlaceDetailsOnMap tutorials (Java and Kotlin) used them. The tutorials weren't part of the root build, so CI never caught it.

Code (Java and Kotlin, kept in parity)

  • Places.initialize → Places.initializeWithNewPlacesApiEnabled.
  • findCurrentPlace → searchNearby over a 100 m CircularBounds around the device's last-known location, ranked by distance, limited to 5 results. Falls back to the map's camera target if no location is available yet.
  • Fields NAME / ADDRESS / LAT_LNG → DISPLAY_NAME / FORMATTED_ADDRESS / LOCATION (the old ones no longer exist in 6.0.2).
  • Java now reads MAPS_API_KEY like the Kotlin version. The root build doesn't define PLACES_API_KEY.

Region tags are unchanged. The published maps_current_place_show_current_place excerpt changes content, which is the point of this PR. The Current Place tutorial text that describes findCurrentPlace will need a matching docs update.

Build

  • Both tutorials are now included in settings.gradle.kts, the build-tutorials CI job and scripts/verify_all.sh, the same way Polygons is.
  • Fixed version catalog aliases that didn't exist (playServicesMaps, coreKtx, espressoCore, kotlinBom, lifecycleViewModelKtx).
  • proguard-android.txt → proguard-android-optimize.txt (current AGP rejects the former).
  • Added play-services-location explicitly. The tutorials use FusedLocationProviderClient but relied on getting it transitively.
  • READMEs: note that Places API (New) must be enabled on the key, explain how to build from the repo root, and set min API to 24.

Testing

  • :tutorials:{java,kotlin}:CurrentPlaceDetailsOnMap:assembleDebug and lintDebug pass.
  • :tutorials:kotlin:Polygons:assembleDebug and spotlessCheck pass.
  • Not run on a device: verifying the nearby search end to end needs a key with Places API (New) enabled.

Places SDK for Android 6.0 removed Places.initialize and
PlacesClient.findCurrentPlace, which both CurrentPlaceDetailsOnMap
tutorials relied on. Use Places.initializeWithNewPlacesApiEnabled and
searchNearby around the device's last-known location instead.

The tutorials were not part of the root build, so the breakage went
unnoticed. Include them in settings.gradle.kts, the build-tutorials CI
job and verify_all.sh, and fix the build files so they compile with the
shared version catalog and current AGP.
@kikoso
kikoso marked this pull request as ready for review October 15, 2026 16:01
@kikoso
kikoso requested a review from dkhawk October 15, 2026 16:20
}
}
// Build a list of likely places to show the user.
likelyPlaceNames = likelyPlaces.map { it.displayName }.toTypedArray()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THB, I have never liked this way of handling the results. These should be data classes that group the fields into an object. WDYT?

@dkhawk dkhawk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good update. Left one comment.

@dkhawk
dkhawk merged commit 6210c6d into main Oct 15, 2026
20 checks passed
@dkhawk
dkhawk deleted the fix/current-place-tutorial-places-6 branch October 15, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants