transistorsoft / flutter_background_geolocation

Sophisticated, battery-conscious background-geolocation & geofencing with motion-detection
https://www.transistorsoft.com/shop/products/flutter-background-geolocation
Other
650 stars 241 forks source link

innacurate getCurrentPosition #1358

Closed sergiomartell closed 1 week ago

sergiomartell commented 1 month ago

Your Environment


## Expected Behavior
<!--- Tell us what should happen -->
I need to get lat long pairs that are with 10 meter accuracy

## Actual Behavior
<!--- Tell us what happens instead -->
[Location {odometer: 0.0, activity: {confidence: 100, type: still}, extras: {}, battery: {level: 0.99, is_charging: false}, uuid: ...., sample: true, age: 15, coords: {altitude: -1.0, heading: -1.0, latitude: 19.423423423423422, accuracy: 2000.0, heading_accuracy: -1.0, altitude_accuracy: 0.0, speed_accuracy: -1.0, speed: -1.0, age: 18, longitude: -99.17595377344381, ellipsoidal_altitude: -1.0}, is_moving: false, timestamp: 2024-09-29T23:57:15.385Z}]

Getting a location ~2km away

## Steps to Reproduce
<!--- reproduce this issue; include code to reproduce, if relevant -->
1.
2.
3.
4.

## Context
<!--- What were you trying to do? -->

## Debug logs
<!-- include iOS / Android logs
- ios XCode logs,
- use #getLog #emailLog methods (@see docs)
- Android: $ adb logcat -s TSLocationManager
-->
<details>
    <summary>Logs</summary>

``` <!-- syntax-highligting:  DO NOT REMOVE -->
PASTE_YOUR_LOGS_HERE

christocracy commented 1 month ago
sergiomartell commented 1 month ago

I know how GPS works, but a 2 kilometer discrepancy is not normal, 50 meters being inside is acceptable.

christocracy commented 1 month ago

It’s due to your device (settings) and / or environment.

open Google maps and you’ll experience the same phenomenon.

sergiomartell commented 1 month ago

Google Maps is getting my location to 5 meters on the device, and we are getting the same result (of an accuracy of 2km) in 2 devices a Pixel 4 and a Samsung Galaxy. And I have tested with the device outside getting also the same result. Any idea why this is happening?

christocracy commented 1 month ago

I have no idea. Are you observing the plug-in logs in adb logcat? See wiki “Debugging”.

I field test almost every day for the last 10 years. I see nothing but excellent accuracy.

sergiomartell commented 1 month ago

These are the logs: I/flutter (12202): "notification": { I/flutter (12202): "layout": "", I/flutter (12202): "title": "", I/flutter (12202): "text": "Location Service activated", I/flutter (12202): "color": "", I/flutter (12202): "channelName": "TSLocationManager", I/flutter (12202): "channelId": "", I/flutter (12202): "smallIcon": "", I/flutter (12202): "largeIcon": "", I/flutter (12202): "priority": -1, I/flutter (12202): "sticky": false, I/flutter (12202): "strings": {}, I/flutter (12202): "actions": [] I/flutter (12202): }, I/flutter (12202): "params": {}, I/flutter (12202): "persist": true, I/flutter (12202): "persistMode": 2, I/flutter (12202): "schedule": [], I/flutter (12202): "scheduleUseAlarmManager": false, I/flutter (12202): "speedJumpFilter": 300, I/flutter (12202): "startOnBoot": true, I/flutter (12202): "stationaryRadius": 50, I/flutter (12202): "stopAfterElapsedMinutes": 0, I/flutter (12202): "stopOnStationary": true, I/flutter (12202): "stopOnTerminate": false, I/flutter (12202): "stopTimeout": 5, I/flutter (12202): "triggerActivities": "in_vehicle, on_bicycle, on_foot, running, walking", I/flutter (12202): "url": "https:\/\/us-central1-aqui-no-d98af.cloudfunctions.net\/\/BackgroundGeolocation", I/flutter (12202): "useSignificantChangesOnly": false, I/flutter (12202): "enabled": true, I/flutter (12202): "schedulerEnabled": false, I/flutter (12202): "trackingMode": 1, I/flutter (12202): "odometer": 0, I/flutter (12202): "isFirstBoot": false, I/flutter (12202): "didLaunchInBackground": false, I/flutter (12202): "didDeviceReboot": false I/flutter (12202): } I/flutter (12202): ╠═════════════════════════════════════════════ I/flutter (12202): I/flutter (12202): 09-30 11:17:31.134 DEBUG [LocationAuthorization withBackgroundPermission] I/flutter (12202): ℹ️ LocationAuthorization: Permission granted I/flutter (12202): 09-30 11:17:31.140 DEBUG [HttpService startMonitoringConnectivityChanges] I/flutter (12202): 🎾 Start monitoring connectivity changes I/flutter (12202): 09-30 11:17:31.141 DEBUG [DeviceSettings startMonitoringPowerSaveChanges] I/flutter (12202): 🎾 Start monitoring powersave changes I/flutter (12202): 09-30 11:17:31.145 INFO [ActivityRecognitionService start] I/flutter (12202): 🎾 Start motion-activity updates I/flutter (12202): 09-30 11:17:31.149 INFO [HeartbeatService stop] I/flutter (12202): 🔴 Stop heartbeat I/flutter (12202): 09-30 11:17:31.170 INFO [TSLocationManager a] I/flutter (12202): ╔═════════════════════════════════════════════ I/flutter (12202): ║ motionchange LocationResult: 1 (343508ms old) I/flutter (12202): ╠═════════════════════════════════════════════ I/flutter (12202): ╟─ 📍 Location[fused 19.423423,-99.175954 hAcc=2000.0 et=+5d5h13m25s942ms], time: 1727716307661 I/flutter (12202): I/flutter (12202): 09-30 11:17:31.171 DEBUG [TSLocationManager a] Median accuracy: 2000.0 I/flutter (12202): 09-30 11:17:31.188 DEBUG [LocationAuthorization withPermission] I/flutter (12202): ℹ️ LocationAuthorization: Permission granted I/flutter (12202): 09-30 11:17:31.213 DEBUG [AbstractService a] I/flutter (12202): 🎾 start [LocationRequestService startId: 1, eventCount: 1] I/flutter (12202): 09-30 11:17:31.215 INFO [SingleLocationRequest startUpdatingLocation] I/flutter (12202): 🔵 [SingleLocationRequest start, action: 1, requestId: 1] I/flutter (12202): 09-30 11:17:31.217 DEBUG [AbstractService a] I/flutter (12202): ⚙️︎ FINISH [LocationRequestService startId: 1, eventCount: 0, sticky: true] I/flutter (12202): 09-30 11:17:31.254 DEBUG [AbstractService a] I/flutter (12202): 🎾 1:1 [LocationRequestService startId: 2, eventCount: 1] I/flutter (12202): 09-30 11:17:31.256 INFO [TSLocationManager a] I/flutter (12202): ╔═════════════════════════════════════════════ I/flutter (12202): ║ motionchange LocationResult: 1 (26ms old) I/flutter (12202): ╠═════════════════════════════════════════════ I/flutter (12202): ╟─ 📍 Location[fused 19.423423,-99.175954 hAcc=2000.0 et=+5d5h19m9s510ms], time: 1727716651229 I/flutter (12202): I/flutter (12202): 09-30 11:17:31.256 DEBUG [TSLocationManager a] Median accuracy: 2000.0 I/flutter (12202): 09-30 11:17:31.259 DEBUG [AbstractService a] I/flutter (12202): ⚙️︎ FINISH [LocationRequestService startId: 2, eventCount: 0, sticky: true] I/flutter (12202): 09-30 11:17:31.421 DEBUG [TSLocationManagerActivity a] locationsettings I/flutter (12202): 09-30 11:17:31.422 DEBUG [TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -2 I/flutter (12202): 09-30 11:17:31.477 DEBUG [TSLocationManagerActivity c] eventCount: 0 I/flutter (12202): 09-30 11:17:31.579 DEBUG [TSLocationManagerActivity onDestroy] I/flutter (12202): D/TSLocationManager(12202): [c.t.l.service.AbstractService a] D/TSLocationManager(12202): 🎾 start [ActivityRecognitionService startId: 1, eventCount: 1] D/TSLocationManager(12202): [c.t.l.s.ActivityRecognitionService a] D/TSLocationManager(12202): 🚘 ️DetectedActivity [type=STILL, confidence=100] D/TSLocationManager(12202): [c.t.l.service.AbstractService a] D/TSLocationManager(12202): ⚙️︎ FINISH [ActivityRecognitionService startId: 1, eventCount: 0, sticky: false] D/TSLocationManager(12202): [c.t.l.service.AbstractService f] D/TSLocationManager(12202): ⚙️︎ ActivityRecognitionService.stopSelfResult(1): true D/TSLocationManager(12202): [c.t.l.service.AbstractService onDestroy] D/TSLocationManager(12202): 🔴 ActivityRecognitionService stopped I/TRuntime.CctTransportBackend(12202): Making request to: https://firebaselogging-pa.googleapis.com/v1/firelog/legacy/batchlog D/TrafficStats(12202): tagSocket(130) with statsTag=0xffffffff, statsUid=-1 I/TRuntime.CctTransportBackend(12202): Status Code: 200

sergiomartell commented 1 month ago

I am still getting the hAcc=2000.0 And the request is for "High Accuracy"

christocracy commented 1 month ago

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0-rc1)

I suggest you update your Android SDK to latest (35). Play Store Console won't even allow apps with targetSdkVersion < 33.

Also, ensure you're using the latest version of play-services-location (see your android/build.gradle ext.playServicesLocationVersion. The latest version is 21.3.0.

christocracy commented 1 month ago

After doing all that, go outside for a 1km walk. Once you return, use Logger.emailLog to fetch the plugin's log database (which saves 3 days worth of logs).

christocracy commented 1 month ago

And try installing the /example app from this repo on your device.

You can also install it from the Play Store: https://play.google.com/store/apps/details?id=com.transistorsoft.flutterbackgroundgeolocationexample&pli=1

The demo app posts locations to the demo server at https://tracker.transistorsoft.com

Screenshot 2024-09-30 at 1 39 03 PM
sergiomartell commented 1 month ago

I am getting this error when moving to SDK 35 Note: /Users/sergiomartell/.pub-cache/hosted/pub.dev/background_fetch-1.3.5/android/src/main/java/com/transistorsoft/flutter/backgroundfetch/BackgroundFetchPlugin.java uses or overrides a deprecated API.

christocracy commented 1 month ago

It's not an error, it's a warning. It was fixed in 1.3.7

github-actions[bot] commented 3 weeks ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 week ago

This issue was closed because it has been inactive for 14 days since being marked as stale.