Skip to content

fix(android): replace deprecated LocationRequest API for Play Services 21+ / Android 12+#453

Open
AmrithVengalath wants to merge 1 commit into
Agontuk:masterfrom
AmrithVengalath:fix-location-request-builder-playservices-21
Open

fix(android): replace deprecated LocationRequest API for Play Services 21+ / Android 12+#453
AmrithVengalath wants to merge 1 commit into
Agontuk:masterfrom
AmrithVengalath:fix-location-request-builder-playservices-21

Conversation

@AmrithVengalath

Copy link
Copy Markdown

Problem

Apps with targetSdkVersion >= 34 crash with NoSuchMethodError when calling
Geolocation.getCurrentPosition() on devices running Google Play Services 21.0.0+
(standard on Android 12+ devices). The crash happens in native Java code and cannot
be caught by JavaScript try/catch.

Root cause: FusedLocationProvider.java uses new LocationRequest() and chained
setter methods (setPriority, setInterval, setFastestInterval,
setSmallestDisplacement) that were removed in Play Services Location 21.0.0.
The LocationRequest.PRIORITY_* integer constants were also superseded by the
Priority interface.

Fix

  • Replace new LocationRequest() + setter chain with LocationRequest.Builder
  • Replace LocationRequest.PRIORITY_* constants with Priority.PRIORITY_*
  • PRIORITY_NO_POWERPriority.PRIORITY_PASSIVE (same value, renamed)

References

…ationRequest.Builder for Play Services 21+ compatibility
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.

1 participant