loup-v / beacons

Flutter beacons plugin for Android and iOS.
Apache License 2.0
78 stars 53 forks source link

Android crashes when monitoring background events #6

Closed adamfuller closed 6 years ago

adamfuller commented 6 years ago

Tested with the example project.

When an enter event is triggered while the app is in the background (still running, not terminated) the app crashes with the following error in the console


E/flutter ( 2680): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 2680): 'file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart': Failed assertion: line 161 pos 16: 'false': cannot parse json to MonitoringState: enter
E/flutter ( 2680): #0      _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:37:39)
E/flutter ( 2680): #1      _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:33:5)
E/flutter ( 2680): #2      _JsonCodec.monitoringStateFromJson (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart)
E/flutter ( 2680): #3      _JsonCodec.monitoringResultFromJson (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart:96:32)
E/flutter ( 2680): #4      _Codec.decodeMonitoringResult (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart:14:18)
E/flutter ( 2680): #5      _Channels.monitoring.<anonymous closure> (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/channel.dart:54:21)
E/flutter ( 2680): #6      _MapStream._handleData (dart:async/stream_pipe.dart:227:21)
E/flutter ( 2680): #7      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:164:13)
E/flutter ( 2680): #8      _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter ( 2680): #9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter ( 2680): #10     _DelayedData.perform (dart:async/stream_impl.dart:578:14)
E/flutter ( 2680): #11     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter ( 2680): #12     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter ( 2680): #13     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 2680): #14     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
E/flutter ( 2680): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter ( 2680): 'file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart': Failed assertion: line 161 pos 16: 'false': cannot parse json to MonitoringState: enter
E/flutter ( 2680): #0      _AssertionError._doThrowNew (dart:core/runtime/liberrors_patch.dart:37:39)
E/flutter ( 2680): #1      _AssertionError._throwNew (dart:core/runtime/liberrors_patch.dart:33:5)
E/flutter ( 2680): #2      _JsonCodec.monitoringStateFromJson (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart)
E/flutter ( 2680): #3      _JsonCodec.monitoringResultFromJson (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart:96:32)
E/flutter ( 2680): #4      _Codec.decodeMonitoringResult (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/codec.dart:14:18)
E/flutter ( 2680): #5      _Channels.monitoring.<anonymous closure> (file:///Users/alfuller/development/flutter/.pub-cache/hosted/pub.dartlang.org/beacons-0.2.1/lib/channel/channel.dart:54:21)
E/flutter ( 2680): #6      _MapStream._handleData (dart:async/stream_pipe.dart:227:21)
E/flutter ( 2680): #7      _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:164:13)
E/flutter ( 2680): #8      _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter ( 2680): #9      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter ( 2680): #10     _DelayedData.perform (dart:async/stream_impl.dart:578:14)
E/flutter ( 2680): #11     _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter ( 2680): #12     _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter ( 2680): #13     _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter ( 2680): #14     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)
I/flutter ( 5830): monitoring: {"data":"enter","isSuccessful":true,"region":{"identifier":"test","ids":["d9407f30-f5f8-466e-aff9-25556b57fe6d"]}}```

My Device:
Samsung Galaxy S7
Android 7.0