Skip to content

feat: upgrade to Places SDK for Android 6.0.2 and migrate removed legacy APIs - #1092

Merged
dkhawk merged 2 commits into
mainfrom
feat/places-6.0.2
Oct 14, 2026
Merged

dkhawk merged 2 commits into
mainfrom
feat/places-6.0.2

Conversation

@dkhawk

@dkhawk dkhawk commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Upgrades com.google.android.libraries.places:places from 5.3.0 to 6.0.2 across all demo and snippet modules, migrates removed Legacy Places APIs, showcases native 6.0.2 Jetpack Compose UI components, replaces reflection with @VisibleForTesting in unit tests, and updates the places-android agent skill with a 4.x/5.x $\rightarrow$ 6.0.x+ migration guide.

Changes Included

  • Version Catalog & Build:
    • Bumps places to 6.0.2 in gradle/libs.versions.toml and snippets/build.gradle.kts.
  • Legacy Places API Removals Migrated (5.3.0 $\rightarrow$ 6.0.2):
    • Replaced removed Autocomplete, AutocompleteSupportFragment, and AutocompleteActivityMode with PlaceAutocomplete and BasicPlaceAutocomplete across :demo-kotlin, :demo-java, and :snippets.
    • Replaced removed FindCurrentPlaceRequest with SearchNearbyRequest + CircularBounds in :demo-java and :snippets.
    • Replaced removed FetchPhotoRequest with FetchResolvedPhotoUriRequest in :demo-java.
    • Replaced removed Places.initialize with Places.initializeWithNewPlacesApiEnabled in :snippets.
    • Updated removed Place.Field constants (NAME $\rightarrow$ DISPLAY_NAME, ADDRESS $\rightarrow$ FORMATTED_ADDRESS, LAT_LNG $\rightarrow$ LOCATION).
  • Places SDK 6.0.2 Native Compose Components (:PlaceDetailsCompose):
    • Updated PlaceDetailsView.kt, MapScreen.kt, and MapViewModel.kt to demonstrate AdvancedPlaceDetailsCompact content slots (basicSectionTop, basicSectionBottom) and PlaceMarker / rememberPlaceMarkerState.
  • Unit Testing Without Reflection (:demo-kotlin):
    • Extracted @VisibleForTesting result handlers (handleAutocompleteResult and handleBasicAutocompleteResult) in PlaceAutocompleteActivity.kt and removed all java.lang.reflect.Field usage in PlaceAutocompleteActivityTest.kt.
  • Skill Documentation (.gemini/skills/places-android/SKILL.md):
    • Added Section 8: Migration Guide (Places SDK 4.x / 5.x $\rightarrow$ 6.0.x+) with complete API and Place.Field mapping tables and code examples, plus Section 5/7 coverage of 6.0.2 Compose and Autocomplete APIs.

Verification

  • ./gradlew assembleDebug testDebugUnitTest passes across all modules.
  • All DevSite // [START ...] / // [END ...] region tags and file paths verified intact.

@kikoso kikoso left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor comments @dkhawk , but looks good!

Comment on lines +233 to +237
val markerState = rememberPlaceMarkerState(
reference = PlaceReference.PlaceId(placeId),
icon = MarkerIcon.Type,
text = MarkerText.Rating
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just to understand it: does rememberPlaceMarkerState key on the reference internally? If not, when the user selects a different place the state stays at the same call site and might keep showing the previous one. Should we wrap this in key(placeId) { ... } to be safe?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Great question! rememberPlaceMarkerState does key on reference internally (remember(reference) { PlaceMarkerStateImpl(reference = reference, icon = icon, text = text) }, where PlaceReference.PlaceId implements structural equals/hashCode on the placeId).

However, wrapping the block in key(placeId) { ... } (and passing placeId into MarkerComposable keys) is even safer because it guarantees that both the PlaceMarkerState and the underlying MarkerComposable lifecycle reset cleanly when switching between places. Added key(placeId) in e44b50e!

Comment thread .gemini/skills/places-android/SKILL.md Outdated
val fields = listOf(Place.Field.ID, Place.Field.DISPLAY_NAME, Place.Field.FORMATTED_ADDRESS)
val intent = Autocomplete.IntentBuilder(AutocompleteActivityMode.OVERLAY, fields)
.build(context)
val intent = PlaceAutocomplete.createIntent(context)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Here we use PlaceAutocomplete.createIntent(context), but the migration table below points to PlaceAutocomplete.IntentBuilder(). Could we use the same entry point in both places, so the skill doesn't mix two patterns?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good catch! Updated AutocompleteSearchButton in Section 7 to use PlaceAutocomplete.IntentBuilder().build(context) in e44b50e so it matches the migration table in Section 8 and the rest of the sample activities.

Comment thread .gemini/skills/places-android/SKILL.md Outdated
Comment on lines +326 to +327
| `Place.Field.TYPES` / `place.types` | `Place.Field.TYPES` (`place.placeTypes: List<String>`) or `Place.Field.PRIMARY_TYPE` (`place.primaryType`) |
| `Place.Field.PRICE_LEVEL` | `Place.Field.PRICE_LEVEL` or `Place.Field.PRICE_RANGE` (`place.priceRange`) |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: these two rows list Place.Field.TYPES and Place.Field.PRICE_LEVEL as both removed and the replacement, which reads a bit confusing. What about saying explicitly that the constant stays and only the getter changes (e.g. place.types -> place.placeTypes)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in e44b50e! Updated both rows to explicitly note that Place.Field.TYPES and Place.Field.PRICE_LEVEL constants remain unchanged, while place.types -> place.placeTypes: List<String> (or Place.Field.PRIMARY_TYPE / place.primaryType) and Place.Field.PRICE_RANGE (place.priceRange) is available for min/max price ranges.

@dkhawk
dkhawk marked this pull request as draft October 14, 2026 17:34
@dkhawk
dkhawk force-pushed the feat/places-6.0.2 branch from 73808c3 to bb325d1 Compare October 14, 2026 18:29
@dkhawk
dkhawk marked this pull request as ready for review October 14, 2026 18:31
@dkhawk
dkhawk requested a review from kikoso October 14, 2026 18:39
@dkhawk
dkhawk merged commit 6a1cd28 into main Oct 14, 2026
10 checks passed
@dkhawk
dkhawk deleted the feat/places-6.0.2 branch October 14, 2026 19:34
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