Lyokone / flutterlocation

A Flutter plugin to easily handle realtime location in iOS and Android. Provides settings for optimizing performance or battery.
MIT License
1.11k stars 815 forks source link

Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference #814

Open BrendanBasson4 opened 1 year ago

BrendanBasson4 commented 1 year ago

Description So I'm receiving a push notification that should then trigger the package to get the location. It works when the app is in the foreground but throws

Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference

when the app is in the background. Note: background mode is enabled.

Expected Behavior I want the location even when the app is in the background.

Steps To Reproduce

  1. Install Firebase messaging.
  2. Set the app in the background with location service in background mode.
  3. receive the background push notification.
  4. trigger getLocation function
  5. See Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference

Tested on:

Other plugins:

firebase_messaging: ^14.2.2

Additional logs

E/MethodChannel#lyokone/location( 6178): Failed to handle method call
E/MethodChannel#lyokone/location( 6178): java.lang.NullPointerException: Attempt to write to field 'io.flutter.plugin.common.MethodChannel$Result com.lyokone.location.FlutterLocation.getLocationResult' on a null object reference
E/MethodChannel#lyokone/location( 6178):    at com.lyokone.location.MethodCallHandlerImpl.onGetLocation(MethodCallHandlerImpl.java:117)
E/MethodChannel#lyokone/location( 6178):    at com.lyokone.location.MethodCallHandlerImpl.onMethodCall(MethodCallHandlerImpl.java:43)
E/MethodChannel#lyokone/location( 6178):    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/MethodChannel#lyokone/location( 6178):    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/MethodChannel#lyokone/location( 6178):    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/MethodChannel#lyokone/location( 6178):    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/MethodChannel#lyokone/location( 6178):    at android.os.Handler.handleCallback(Handler.java:883)
E/MethodChannel#lyokone/location( 6178):    at android.os.Handler.dispatchMessage(Handler.java:100)
E/MethodChannel#lyokone/location( 6178):    at android.os.Looper.loop(Looper.java:214)
E/MethodChannel#lyokone/location( 6178):    at android.app.ActivityThread.main(ActivityThread.java:7356)
E/MethodChannel#lyokone/location( 6178):    at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#lyokone/location( 6178):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
E/MethodChannel#lyokone/location( 6178):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
LassazVegaz commented 1 year ago

I am getting the same

naiadelali commented 9 months ago

same here

davidalonsobadia commented 8 months ago

same here

fredyrx commented 7 months ago

same here

darul9061 commented 1 week ago

same here