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

🐛 [firebase_core] Unable to establish connection on channel #9088

Closed
deepsan98 opened this issue Jul 13, 2022 · 13 comments
Closed

🐛 [firebase_core] Unable to establish connection on channel #9088

deepsan98 opened this issue Jul 13, 2022 · 13 comments
Labels
resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working

Comments

@deepsan98
Copy link

Bug report

Describe the bug
When I launch the app, I get the following error:

E/flutter ( 2714): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
E/flutter ( 2714): #0      FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:205:7)
E/flutter ( 2714): <asynchronous suspension>
E/flutter ( 2714): #1      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29:44)
E/flutter ( 2714): <asynchronous suspension>
E/flutter ( 2714): #2      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:73:7)
E/flutter ( 2714): <asynchronous suspension>
E/flutter ( 2714): #3      Firebase.initializeApp (package:firebase_core/src/firebase.dart:42:31)
E/flutter ( 2714): <asynchronous suspension>
E/flutter ( 2714): #4      main (package:falabella/main.dart:31:3)
E/flutter ( 2714): <asynchronous suspension>
E/flutter ( 2714): 

Steps to reproduce

Steps to reproduce the behavior:

  1. Add these dependencies in pubspec.yaml:
firebase_core 1.19.1
firebase_crashlytics: ^2.8.4
firebase_analytics: ^9.1.12
  1. Launch the app

Expected behavior

The app should launch without any error message.


Additional informations

I already have tried putting to put firebase_core_platform_interface: 4.4.1 in dependency_overrides or in dependencies.
I only have 3 firebase packages (mentioned above) and they are all at last version available.


Flutter doctor

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.0.2, on macOS 12.0.1 21A559 darwin-arm, locale it-IT)
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.69.0)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
@deepsan98 deepsan98 added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jul 13, 2022
@deepsan98 deepsan98 changed the title 🐛 [firebase_core] Your issue title here 🐛 [firebase_core] Unable to establish connection on channel Jul 13, 2022
@mustafa-707
Copy link

same here ! , also im facing a problem with Firebase/Crashlytics in pod install

[!] CocoaPods could not find compatible versions for pod "Firebase/Crashlytics":
  In snapshot (Podfile.lock):
    Firebase/Crashlytics (= 8.15.0)

  In Podfile:
    firebase_crashlytics (from `.symlinks/plugins/firebase_crashlytics/ios`) was resolved to 2.8.5, which depends on
      Firebase/Crashlytics (= 9.2.0)


You have either:
 * changed the constraints of dependency `Firebase/Crashlytics` inside your development pod `firebase_crashlytics`.
   You should run `pod update Firebase/Crashlytics` to apply changes you've made.

@darshankawar darshankawar added the triage Issue is currently being triaged. label Jul 13, 2022
@darshankawar
Copy link

@deepsan98
Check similar SO link and underlying solution and see if they help : https://stackoverflow.com/questions/72833245/calling-firebase-initializeapp-returns-unable-to-establish-connection-on-chan/72835948#72835948

Also, see if this helps: #9028 (comment)

Moreover, try upgrading all your firebase plugins you are using to latest versions and see if it works:

https://pub.dev/packages/firebase_core/changelog#1192
https://pub.dev/packages/firebase_crashlytics/changelog#285
https://pub.dev/packages/firebase_analytics/changelog#920

Similar issue : #9022

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 13, 2022
@deepsan98
Copy link
Author

@darshankawar I already tried all your suggested solutions before opening this issue.

And, #9022 is not similar to my issue. I don't think the issue described by @mustafa-707 has anything to do with my situation.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 13, 2022
@ChristianEdwardPadilla
Copy link
Contributor

Upgrading to the latest releases did not help me either, I am still seeing a PlatformException on call to await Firebase.initializeApp() on Android.

@ChristianEdwardPadilla
Copy link
Contributor

Found the issue for me. It was that firebase_core was not being registered. This was an issue with my specific setup and not a bug with this repo at all. For those running into unexpected PlatformException, consider checking your native registration calls to be sure all your plugins' registerWith calls are being made.

@darshankawar
Copy link

@deepsan98 Check above comment / solution and see if its the case with you as well.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 14, 2022
@deepsan98
Copy link
Author

While waiting for answers, I checked if the error mentioned above is encountered also on Android, but no, on android works fine.
This issue regards only iOS.


Found the issue for me. It was that firebase_core was not being registered. This was an issue with my specific setup and not a bug with this repo at all. For those running into unexpected PlatformException, consider checking your native registration calls to be sure all your plugins' registerWith calls are being made.

My GeneratedPluginRegistrant.m file contains these lines, that seem correct to me:

#if __has_include(<firebase_analytics/FLTFirebaseAnalyticsPlugin.h>)
#import <firebase_analytics/FLTFirebaseAnalyticsPlugin.h>
#else
@import firebase_analytics;
#endif

#if __has_include(<firebase_core/FLTFirebaseCorePlugin.h>)
#import <firebase_core/FLTFirebaseCorePlugin.h>
#else
@import firebase_core;
#endif

#if __has_include(<firebase_crashlytics/FLTFirebaseCrashlyticsPlugin.h>)
#import <firebase_crashlytics/FLTFirebaseCrashlyticsPlugin.h>
#else
@import firebase_crashlytics;
#endif

and the method registerWithRegistry contains:

[FLTFirebaseAnalyticsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseAnalyticsPlugin"]];
[FLTFirebaseCorePlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseCorePlugin"]];
[FLTFirebaseCrashlyticsPlugin registerWithRegistrar:[registry registrarForPlugin:@"FLTFirebaseCrashlyticsPlugin"]];

so the native calls seem fine to me.

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 14, 2022
@darshankawar
Copy link

Thanks for the update @deepsan98
I actually hit this error while running a sample firebase_remote_config example which had following dependencies:

firebase_core and firebase_remote_config and were on old versions. When I only updated firebase_remote_config to latest but kept firebase_core as-is, I got the same error as you reported:

console error log

Launching lib/main.dart on iPhone 13 in debug mode...
Upgrading AppFrameworkInfo.plist
Upgrading Podfile
Upgrading Info.plist
Running pod install...
Running Xcode build...
Xcode build done.                                           61.3s
Debug service listening on ws://127.0.0.1:52412/10T1n91UcO8=/ws
Syncing files to device iPhone 13...
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:205:7)
<asynchronous suspension>
#1      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29:44)
<asynchronous suspension>
#2      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:73:7)
<asynchronous suspension>
#3      Firebase.initializeApp (package:firebase_core/src/firebase.dart:42:31)
<asynchronous suspension>
#4      setupRemoteConfig (package:triage/main.dart:79:3)
<asynchronous suspension>

But when I upgraded firebase_core to latest version, ran again, it compiled and built the app properly:

  Launching lib/main.dart on iPhone 13 in debug mode...
Running Xcode build...
Xcode build done.                                           16.2s
Debug service listening on ws://127.0.0.1:52765/CPDnXJDu5lY=/ws
Syncing files to device iPhone 13...

So after upgrading plugin versions, try deleting the podfile.lock and then try running again and see if it helps.

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 14, 2022
@deepsan98
Copy link
Author

I already updated all firebase dependencies to latest version and also tried to delete podfile.lock

Still not working

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Jul 14, 2022
@darshankawar
Copy link

firebase_core 1.19.1

I see that you are using direct plugin version and not with a caret sign (^) ? Is it a typo or purposely ?

Can you try using firebase_core: ^1.19.2 and confirm ?

@darshankawar darshankawar added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Jul 15, 2022
@deepsan98
Copy link
Author

It is a typo. I am currently using firebase_core: ^1.19.2.

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Jul 15, 2022
@google-oss-bot google-oss-bot added the Needs Attention This issue needs maintainer attention. label Jul 15, 2022
@deepsan98
Copy link
Author

I finally managed to solve this issue. Looking at pubspec.lock turns out a dependency (flutter_apns) was using an older version of firebase_messaging and it was not updated with pub upgrade because of some conflicts.

Removing flutter_apns solved my situation.

@darshankawar darshankawar added resolution: solution-provided A solution has been provided in the issue. and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jul 18, 2022
@KKimj
Copy link
Contributor

KKimj commented Jul 19, 2022

Hello folks!

Can I use only latest version of Firebase Core, 1.19.2?

I want to use firebase_core: 1.18.0, because of pre-compiled firebase-ios-sdk by invertase/firestore-ios-sdk-frameworks.

I encounter same error, ( Unable to establish connection .. ) on firebase core 1.18.0!

Thanks!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants