-
Notifications
You must be signed in to change notification settings - Fork 238
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
getCurrentPosition doesn't work on Android. #272
Comments
Same here! |
I have this same issue, but when u set enableHighAccuracy: false, it will work or else try removing the maximumAge parameter. But when maximumAge parameter was removed my accuracy of location was very bad comparing to when enableHighAccuracy was set to false. |
Having the same issue in version The error seems similar:
I am guessing for my case the library is not detecting that I have allowed the location permission. I tried in different ways but it's always the same. After upgrading to the latest version
In my code I have tried all the possible scenarios.
Always after accepting the permission request on the OS dialogs, I get the correct response from the
Nevertheless, the geolocation library seems to have a different opinion on that matter. Also, I checked the settings of the app and the location permissions are granted, which means that the Also if you try using
Tested on For iOS everything works as expected. |
Any way to make this library actually work on Android? |
from google search = "ACCESS_FINE_LOCATION includes GPS data in reporting user location while ACCESS_COARSE_LOCATION includes data from the most battery-efficient non-GPS provider available (e.g., the network)." I left only I have removed useEffect(() => {
Geolocation.getCurrentPosition(
(position) => {
console.log(position.coords)
},
(error) => {
console.error(error);
},
{
enableHighAccuracy: false,
timeout: 10000,
}
);
}, []); Tested on 2 android 11 devices, both were accurate |
Same issue on "react-native": "0.71.12", Works pretty well on iOS. Anyone with a workaround ? |
I'm mistaken, this doesn't work for me. I checked in AndroidStudio and found that |
So just to confirm @lazyflog - this seems to be an issue on Android where setting enableHighAccuracy to true will always time out? This is what I'm experiencing from my side. @michalchudziak - do you have any idea why this could be? |
disabling hight accuracy worked for me. |
set enableHighAccuracy: false works for me on android. wonder it started to happen recently since it is not documented. |
Any updates on this? |
Same for us as in the issue description from @lazyflog. |
In some how, that's be appear if your're working with your device in a inside of building and the GPS signal cannot get. So you have 2 options: Try with
That's gonna to do more time to your device to get the GPS Signal. That work's for me. |
Hey guys. I had the same problem and was wondering what was happening. I see this setting https://www.npmjs.com/package/@react-native-community/geolocation#setrnconfiguration After setting this in Geolocation.setRNConfiguration, this problem goes away and its working in all android versions. The problem is that, the emulators in android studio doesn't come with Google play APIs. I think this comes only from API level 33 (Android 13). Older emulators come with just Google APIs. So this setting helps to fall back to android and provide the location information. Please test in your code let me know. Eager to know. |
+1 |
Same issue( |
We have the same issue, I can provide log if needed. |
I didn't find a way to solve it in my case. I switched to that: react-native-geolocation-service, and it's working as expected for me. |
Did you get same coords for both of this library? |
I switched to the react-native-geolocation-service to get the desired behavior, but it seems to have been unmaintained for a while, so it's not a long-term solution. |
I just had this same error, for me it was the |
Same here! Any solution? |
The issue is not resolved yet even in the latest version |
`const requestLocationPermission = async () => { export const getLocation = async () => { if (!hasLocationPermission) { // Configure geolocation // Get current position |
Environment
System:
OS: macOS 13.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 81.98 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.15.0 - ~/.nvm/versions/node/v18.15.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v18.15.0/bin/npm
Watchman: 2023.07.24.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.12.1 - /Users/yangjongseon/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
Android SDK: Not Found
IDEs:
Android Studio: Giraffe 2022.3.1 Giraffe 2022.3.1
Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
Languages:
Java: 11.0.17 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.8 => 0.71.8
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found
Platforms
Android
Versions
Description
When I try to get the position by simply using getCurrentPosition, I get the error below on Android only.
enableHighAccuracy: false
This works fine, but I want to get the location via GPS.Reproducible Demo
The text was updated successfully, but these errors were encountered: