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

ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized #28

Closed
PocketDaniel opened this issue Jan 6, 2020 · 3 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@PocketDaniel
Copy link

After Alice update i am getting those errors on application start-up. Thought app is running just fine, i can't access Alice (no push-notification, shake gesture doesn't bring up Alice UI).

Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.
If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.
#0      defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.dart:76:7)
#1      defaultBinaryMessenger (package:flutter/src/services/binary_messenger.dart:89:4)
#2      MethodChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:140:62)
#3      MethodChannel.setMethodCallHandler (package:flutter/src/services/platform_channel.dart:368:5)
#4      FlutterLocalNotificationsPlugin.initialize (package:flutter_local_notifications/src/flutter_local_notifications.dart:94:14)
#5      AliceCore._initializeNotificationsPlugin (package:alice/core/alice_core.dart:57:38)
#6      new AliceCore (package:alice/core/alice_core.dart:32:7)
#7      new Alice (package:alice/alice.dart:26:13)
#8      ApiCore.init (package:oversee_core_package/Api/Core/ApiCore.dart:29:16)
#9      new App (package:csq_prototype_app/main.dart:34:32)
#10     main (package:csq_prototype_app/main.dart:26:10)
#11     _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)
#12     _rootRun (dart:async/zone.dart:1126:13)
#13     _CustomZone.run (dart:async/zone.dart:1023:19)
#14     _runZoned (dart:async/zone.dart:1518:10)
#15     runZoned (dart:async/zone.dart:1502:12)
#16     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)
#17     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
#18     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
Unhandled Exception: ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
If you're running an application and need to access the binary messenger before `runApp()` has been called (for example, during plugin initialization), then you need to explicitly call the `WidgetsFlutterBinding.ensureInitialized()` first.
If you're running a test, you can call the `TestWidgetsFlutterBinding.ensureInitialized()` as the first line in your test's `main()` method to initialize the binding.
#0      defaultBinaryMessenger.<anonymous closure> (package:flutter/src/services/binary_messenger.dart:76:7)
#1      defaultBinaryMessenger (package:flutter/src/services/binary_messenger.dart:89:4)
#2      EventChannel.binaryMessenger (package:flutter/src/services/platform_channel.dart:484:62)
#3      EventChannel.receiveBroadcastStream.<anonymous closure> (package:flutter/src/services/platform_channel.dart:504:7)
#4      _runGuarded (dart:async/stream_controller.dart:807:24)
#5      _BroadcastStreamController._subscribe (dart:async/broadcast_stream_controller.dart:215:7)
#6      _ControllerStream._createSubscription (dart:async/stream_controller.dart:820:19)
#7      _StreamImpl.listen (dart:async/stream_impl.dart:474:9)
#8      new _ForwardingStreamSubscription (dart:async/stream_pipe.dart:125:10)
#9      _ForwardingStream._createSubscription (dart:async/stream_pipe.dart:93:16)
#10     _ForwardingStream.listen (dart:async/stream_pipe.dart:88:12)
#11     ShakeDetector.startListening (package:shake/shake.dart:48:46)
#12     new ShakeDetector.autoStart (package:shake/shake.dart:43:5)
#13     new AliceCore (package:alice/core/alice_core.dart:36:37)
#14     new Alice (package:alice/alice.dart:26:13)
#15     ApiCore.init (package:oversee_core_package/Api/Core/ApiCore.dart:29:16)
#16     new App (package:csq_prototype_app/main.dart:34:32)
#17     main (package:csq_prototype_app/main.dart:26:10)
#18     _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:239:25)
#19     _rootRun (dart:async/zone.dart:1126:13)
#20     _CustomZone.run (dart:async/zone.dart:1023:19)
#21     _runZoned (dart:async/zone.dart:1518:10)
#22     runZoned (dart:async/zone.dart:1502:12)
#23     _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:231:5)
#24     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:307:19)
#25     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Flutter doctor output:

[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.14.5 18F132, locale en-LV)
    • Flutter version 1.12.13+hotfix.5 at /Users/danielsklinge/Flutter
    • Framework revision 27321ebbad (4 weeks ago), 2019-12-10 18:15:01 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
    • Android SDK at /Users/danielsklinge/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.1
    • ANDROID_HOME = /Users/danielsklinge/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3, Build version 11C29
    • CocoaPods version 1.7.5

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 39.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.4.1

[✓] Connected device (1 available)
    • iPhone • 00008020-000A49E92212002E • ios • iOS 13.3

Any ideas?

@jhomlala
Copy link
Owner

Can you share your example? Especially class with main.

@jhomlala
Copy link
Owner

Also try call WidgetsFlutterBinding.ensureInitialized() before init Alice.

@jhomlala jhomlala self-assigned this Jan 26, 2020
@jhomlala jhomlala added the help wanted Extra attention is needed label Jan 26, 2020
@PocketDaniel
Copy link
Author

Also try call WidgetsFlutterBinding.ensureInitialized() before init Alice.

Yes, this helped. Missed info about this after i updated Flutter version. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants