Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not invoke RNFusedLocation.startObserving #431

Open
Off2Race opened this issue Dec 14, 2023 · 3 comments
Open

Could not invoke RNFusedLocation.startObserving #431

Off2Race opened this issue Dec 14, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@Off2Race
Copy link

Environment

System:
OS: macOS 12.6.3
CPU: (10) arm64 Apple M1 Max
Memory: 108.56 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 16.14.2 - ~/.asdf/installs/nodejs/16.14.2/bin/node
Yarn: 1.22.18 - /opt/homebrew/bin/yarn
npm: 8.5.0 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2022.03.21.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.14.3 - /Users/mikeloos/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
Android SDK: Not Found
IDEs:
Android Studio: 2022.1 AI-221.6008.13.2211.9514443
Xcode: 14.2/14C18 - /usr/bin/xcodebuild
Languages:
Java: 11.0.14.1 - /Users/mikeloos/.asdf/shims/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.5 => 0.67.5
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Platforms

Android

Versions

Please add the used versions/branches

  • Android: 12
  • react-native-geolocation-service: 5.3.1
  • react-native: 0.67.5
  • react: 17.0.2

Description

When I call geoLocation.watchPosition on Android, the app will crash with the error:

Could not invoke RNFusedLocation.startObserving

See below:

Screenshot_1702584957

I've been able to reproduce the issue on the Android emulator but I first detected it when I got a Sentry log from a production user that was experiencing the same crash.

Here are some screenshots from the stack trace that Sentry captured:

Sentry-1 Sentry-2

No issues on iOS. The crash only occurs on Android. And, oddly enough, the issue appears to have just started occurring about 2 weeks ago. Before that, and for several months prior, the same code has been working without any problems.

Reproducible Demo

import Geolocation from 'react-native-geolocation-service';

const currentPositionOptions = { enableHighAccuracy: true, timeout: 20000, maximumAge: 0 };
const watchOptions = {
	...currentPositionOptions,
	maximumAge: 1000,
	distanceFilter: 1,
};

const onNewPosition = (position: GeoPosition) => {
	// save the position in redux
};

const onError = (functionName: string) => (error: GeoError) => {
	// write an error message to logging service
};

const newWatchId = Geolocation.watchPosition(
	onNewPosition,
	onError('watchPosition'),
	watchOptions,
);

Expected Results

Not crash

@Off2Race Off2Race added the bug Something isn't working label Dec 14, 2023
@Off2Race
Copy link
Author

Ok, I did some investigation myself and it appears that this is a known issue with recent updates to Google Play services. See the link below for more details:

https://issuetracker.google.com/issues/256046114

Fortunately, there was a fix made last year in version 21.0.1 of the play-services-location library. To leverage this fix, I added the following line in my android > build.gradle:

buildscript {
  ext {
    ....
    playServicesLocationVersion = "21.0.1". <----- ADD THIS LINE
  }

Once I made this change and rebuilt the app, the crash went away.

@Agontuk – To avoid this issue for others, you might consider changing the default version for react-native-geolocation-service and kick out a new version.

@Off2Race
Copy link
Author

And, of course, after I figured all this out, I found #424 which basically came to the same conclusion :)

Sorry for the noise...

@abura1han
Copy link

Ok, I did some investigation myself and it appears that this is a known issue with recent updates to Google Play services. See the link below for more details:

https://issuetracker.google.com/issues/256046114

Fortunately, there was a fix made last year in version 21.0.1 of the play-services-location library. To leverage this fix, I added the following line in my android > build.gradle:

buildscript {
  ext {
    ....
    playServicesLocationVersion = "21.0.1". <----- ADD THIS LINE
  }

Once I made this change and rebuilt the app, the crash went away.

@Agontuk – To avoid this issue for others, you might consider changing the default version for react-native-geolocation-service and kick out a new version.

Worked for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants