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

[Bug]: Add Geofence crash the android app #1433

Open
2 of 3 tasks
saravananmnm opened this issue Feb 28, 2025 · 3 comments
Open
2 of 3 tasks

[Bug]: Add Geofence crash the android app #1433

saravananmnm opened this issue Feb 28, 2025 · 3 comments

Comments

@saravananmnm
Copy link

saravananmnm commented Feb 28, 2025

Required Reading

  • Confirmed

Plugin Version

4.12.0

Mobile operating-system(s)

  • iOS
  • Android

What do you require assistance about?

When i try to add geofences. it's getting crashed.

[Optional] Plugin Code and/or Config

 if(radiusCollOrders.isNotEmpty){
      await Future.forEach(radiusCollOrders, (AuctionInfoModel? rad) async {
        await LocationTrackByTransistor.addGeoFence(rad!,isForCollection: true);
      });
    }

static Future<void> addGeoFence(AuctionInfoModel infoModel,{bool? isForCollection = false}) async {
    var geoFence = bg.Geofence(
        loiteringDelay: 5000,extras: {isForCollection != true? infoModel.pODSyncupId!:infoModel.pOBSyncupId!:infoModel},
        identifier: isForCollection != true? infoModel.pODSyncupId!:infoModel.pOBSyncupId!,
        latitude: isForCollection != true? infoModel.deliveryLat : infoModel.collectionLat,
        longitude: isForCollection != true? infoModel.deliveryLong : infoModel.collectionLong,
        radius: double.tryParse('${isForCollection != true?infoModel.delSiteRadius:infoModel.colSiteRadius}'),notifyOnDwell: false,
        notifyOnEntry: true,
        notifyOnExit: true);
    var exists = await bg.BackgroundGeolocation.geofenceExists(isForCollection != true? infoModel.pODSyncupId!:infoModel.pOBSyncupId!);
    if (exists != true) {
      bg.BackgroundGeolocation.addGeofences([geoFence]);
    }
  }

[Optional] Relevant log output

[+8443 ms] E/AndroidRuntime(23018): FATAL EXCEPTION: pool-13-thread-7
[        ] E/AndroidRuntime(23018): Process: com.iex.driver.dev, PID: 23018
[        ] E/AndroidRuntime(23018): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-7
[        ] E/AndroidRuntime(23018): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(:1280)
[        ] E/AndroidRuntime(23018): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(:952)
[        ] E/AndroidRuntime(23018): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(:169)
[        ] E/AndroidRuntime(23018): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(:238)
[        ] E/AndroidRuntime(23018): 	at com.transistorsoft.flutter.backgroundgeolocation.BackgroundGeolocationModule$24.onResult(:754)
[        ] E/AndroidRuntime(23018): 	at com.transistorsoft.locationmanager.geofence.TSGeofenceManager$f.run(Unknown Source:14)
[        ] E/AndroidRuntime(23018): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[        ] E/AndroidRuntime(23018): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[        ] E/AndroidRuntime(23018): 	at java.lang.Thread.run(Thread.java:1012)
[  +30 ms] I/flutter (23018): ===ON_HEART_BEAT__FOREGROUND===[HeartbeatEvent location:[Location {odometer: 6080716.0, activity: {confidence: 100, type: still}, extras: {}, event: heartbeat, battery: {level: 1.0, is_charging: true}, uuid: b2650792-7e51-4e92-9766-8ffebfbaf131, age: 47956, coords: {altitude: 0.7, heading: -1.0, latitude: 9.6979392, accuracy: 22.5, heading_accuracy: 45.0, altitude_accuracy: 93.6, speed_accuracy: 1.5, speed: -1.0, age: 47971, longitude: 78.4721807, ellipsoidal_altitude: 0.7}, is_moving: false, timestamp: 2025-02-28T08:50:07.440Z}]]
[   +5 ms] E/TSLocationManager(23018): [c.t.l.a.BackgroundGeolocation$w0 uncaughtException] 
[        ] E/TSLocationManager(23018):   ‼️  Uncaught Exception: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-7
[        ] E/TSLocationManager(23018): {"activityRecognitionInterval":10000,"allowIdenticalLocations":false,"authorization":{},"autoSync":true,"autoSyncThreshold":0,"backgroundPermissionRationale":{"title":"Allow {applicationName} to access this device's location even when closed or not in use?","message":"[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.","positiveAction":"Change to \"{backgroundPermissionOptionLabel}\"","negativeAction":""},"batchSync":false,"configUrl":"","debug":false,"deferTime":0,"desiredAccuracy":-1,"desiredOdometerAccuracy":100,"disableAutoSyncOnCellular":false,"disableElasticity":false,"disableLocationAuthorizationAlert":false,"disableMotionActivityUpdates":false,"disableProviderChangeRecord":false,"disableStopDetection":false,"distanceFilter":100,"elasticityMultiplier":4,"enableHeadless":true,"enableTimestampMeta":false,"extras":{},"fastestLocationUpdateInterval":-1,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":true,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{},"headlessJobService":"com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask","heartbeatInterval":60,"httpRootProperty":"location","httpTimeout":60000,"isMoving":false,"locationAuthorizationRequest":"Always","locationTemplate":"","locationTimeout":60,"locationUpdateInterval":1000,"locationsOrderDirection":"ASC","logLevel":5,"logMaxDays":3,"maxBatchSize":-1,"maxDaysToPersist":1,"maxMonitoredGeofences":97,"maxRecordsToPersist":-1,"method":"POST","minimumActivityRecognitionConfidence":75,"motionTriggerDelay":0,"notification":{"layout":"","title":"IEX live location","text":"You are available for work","color":"","channelName":"IEXBackgroundLocationTracking","channelId":"","smallIcon":"","largeIcon":"","priority":1,"sticky":true,"strings":{},"actions":[]},"params":{},"persist":true,"persistMode":2,"schedule":[],"scheduleUseAlarmManager":false,"speedJumpFilter":300,"startOnBoot":true,"stationaryRadius":10,"stopAfterElapsedMinutes":0,"stopOnStationary":false,"stopOnTerminate":false,"stopTimeout":5,"triggerActivities":"in_vehicle, on_bicycle, on_foot, running, walking","url":"","useSignificantChangesOnly":false,"enabled":true,"schedulerEnabled":false,"trackingMode":0,"odometer":6080716,"isFirstBoot":false,"didLaunchInBackground":false,"didDeviceReboot":false}
[        ] E/TSLocationManager(23018): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-7
[        ] E/TSLocationManager(23018): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(:1280)
[        ] E/TSLocationManager(23018): 	at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(:952)
[        ] E/TSLocationManager(23018): 	at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(:169)
[        ] E/TSLocationManager(23018): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(:238)
[        ] E/TSLocationManager(23018): 	at com.transistorsoft.flutter.backgroundgeolocation.BackgroundGeolocationModule$24.onResult(:754)
[        ] E/TSLocationManager(23018): 	at com.transistorsoft.locationmanager.geofence.TSGeofenceManager$f.run(Unknown Source:14)
[        ] E/TSLocationManager(23018): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[        ] E/TSLocationManager(23018): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
[        ] E/TSLocationManager(23018): 	at java.lang.Thread.run(Thread.java:1012)
@saravananmnm saravananmnm changed the title [Help Wanted]: Add Geofence crash the android app bug: Add Geofence crash the android app Feb 28, 2025
@saravananmnm saravananmnm changed the title bug: Add Geofence crash the android app [Bug]: Add Geofence crash the android app Feb 28, 2025
@christocracy
Copy link
Member

4.12.0

See CHANGELOG and install latest version.

@saravananmnm
Copy link
Author

saravananmnm commented Mar 3, 2025

@christocracy

we are using flutter sdk 2.5.3
background geolocation plugin 4.14.0

still facing same issue. can you have a any workarounds for that.

[ +3 ms] E/TSLocationManager(16694): [c.t.l.a.BackgroundGeolocation$w0 uncaughtException] [ ] E/TSLocationManager(16694): ‼️ Uncaught Exception: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-4 [ ] E/TSLocationManager(16694): {"activityRecognitionInterval":10000,"allowIdenticalLocations":false,"authorization":{},"autoSync":true,"autoSyncThreshold":0,"backgroundPermissionRationale":{"title":"Allow {applicationName} to access this device's location even when closed or not in use?","message":"[CHANGEME] This app collects location data for FEATURE X and FEATURE Y.","positiveAction":"Change to \"{backgroundPermissionOptionLabel}\"","negativeAction":""},"batchSync":false,"configUrl":"","debug":true,"deferTime":0,"desiredAccuracy":-1,"desiredOdometerAccuracy":100,"disableAutoSyncOnCellular":false,"disableElasticity":false,"disableLocationAuthorizationAlert":false,"disableMotionActivityUpdates":false,"disableProviderChangeRecord":false,"disableStopDetection":false,"distanceFilter":100,"elasticityMultiplier":4,"enableHeadless":true,"enableTimestampMeta":false,"extras":{},"fastestLocationUpdateInterval":-1,"foregroundService":true,"geofenceInitialTriggerEntry":true,"geofenceModeHighAccuracy":true,"geofenceProximityRadius":1000,"geofenceTemplate":"","headers":{},"headlessJobService":"com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask","heartbeatInterval":60,"httpRootProperty":"location","httpTimeout":60000,"isMoving":false,"locationAuthorizationRequest":"Always","locationTemplate":"","locationTimeout":60,"locationUpdateInterval":1000,"locationsOrderDirection":"ASC","logLevel":5,"logMaxDays":3,"maxBatchSize":-1,"maxDaysToPersist":1,"maxMonitoredGeofences":97,"maxRecordsToPersist":-1,"method":"POST","minimumActivityRecognitionConfidence":75,"motionTriggerDelay":0,"notification":{"layout":"","title":"IEX live location","text":"You are available for work","color":"","channelName":"IEXBackgroundLocationTracking","channelId":"","smallIcon":"","largeIcon":"","priority":1,"sticky":true,"strings":{},"actions":[]},"params":{},"persist":true,"persistMode":2,"schedule":[],"scheduleUseAlarmManager":false,"speedJumpFilter":300,"startOnBoot":true,"stationaryRadius":10,"stopAfterElapsedMinutes":0,"stopOnStationary":false,"stopOnTerminate":false,"stopTimeout":5,"triggerActivities":"in_vehicle, on_bicycle, on_foot, running, walking","url":"","useSignificantChangesOnly":false,"enabled":true,"schedulerEnabled":false,"trackingMode":1,"odometer":6080821.5,"isFirstBoot":false,"didLaunchInBackground":false,"didDeviceReboot":false} [ ] E/TSLocationManager(16694): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: pool-13-thread-4 [ ] E/TSLocationManager(16694): at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(:1280) [ ] E/TSLocationManager(16694): at io.flutter.embedding.engine.FlutterJNI.invokePlatformMessageResponseCallback(:952) [ ] E/TSLocationManager(16694): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(:169) [ ] E/TSLocationManager(16694): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(:238) [ ] E/TSLocationManager(16694): at com.transistorsoft.flutter.backgroundgeolocation.BackgroundGeolocationModule$24.onResult(:754) [ ] E/TSLocationManager(16694): at com.transistorsoft.locationmanager.geofence.TSGeofenceManager$f.run(Unknown Source:14) [ ] E/TSLocationManager(16694): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [ ] E/TSLocationManager(16694): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) [ ] E/TSLocationManager(16694): at java.lang.Thread.run(Thread.java:1012)

@christocracy
Copy link
Member

This is an ancient error from an ancient version of flutter and this plug-in.

Time to upgrade your Flutter SDK.

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

No branches or pull requests

2 participants