0

Going crazy. Firebase just WON'T let my app run on the Android emulator, had no issues before I upgraded Flutter. Note that on iOS, there are NO issues and the app runs just fine.

I am using the following packages (I have updated all to latest versions):

  firebase_core: ^2.1.0
  firebase_messaging: ^14.0.2
  firebase_core_platform_interface: ^4.4.1

The error message I keep getting is 'PlatformException(channel-error, Unable to establish connection on channel., null, null)':

E/flutter (32105): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
E/flutter (32105): #0      FirebaseCoreHostApi.initializeCore
package:firebase_core_platform_interface/…/pigeon/messages.pigeon.dart:199
E/flutter (32105): <asynchronous suspension>
E/flutter (32105): #1      MethodChannelFirebase._initializeCore
package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:29
E/flutter (32105): <asynchronous suspension>
E/flutter (32105): #2      MethodChannelFirebase.initializeApp
package:firebase_core_platform_interface/…/method_channel/method_channel_firebase.dart:73
E/flutter (32105): <asynchronous suspension>
E/flutter (32105): #3      Firebase.initializeApp
package:firebase_core/src/firebase.dart:43
E/flutter (32105): <asynchronous suspension>
E/flutter (32105): #4      main
package:cadsys_adm/main.dart:13
E/flutter (32105): <asynchronous suspension>
E/flutter (32105):

My main() code:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(MyApp());
}

Here is the results of FLUTTER PUB OUTDATED:

enter image description here

Here is an interesting thing I noticed: my pubspec is set to version 4.4.1 of firebase_core_platform_interface, but seems a version 4.5.1 is being used?

enter image description here

I have beeb stuck at this issue for over month at least, even had to take a break from looking at it for two weeks because it is making me crazy. I have googled, tested other solutions, downgraded the packages, tried providing specific options (API, projectID and so on) when initializing, nothing works.

I sincerely hope someone can help.

Robert Benedetto
  • 1,590
  • 2
  • 29
  • 52
  • Have you followed this? https://stackoverflow.com/questions/72880037/unhandled-exception-platformexceptionchannel-error-unable-to-establish-connec – Vikas Oct 21 '22 at 11:51
  • Also this: https://stackoverflow.com/questions/72833245/calling-firebase-initializeapp-returns-unable-to-establish-connection-on-chan – Vikas Oct 21 '22 at 11:52
  • Yup, have seen both of them. I even commented on one of them. – Robert Benedetto Oct 21 '22 at 12:03
  • try forcing your deps to specific versions eg firebase_core_platform_interface: 4.4.1 – griffins Oct 21 '22 at 12:31
  • @griffins how would I do that? – Robert Benedetto Oct 21 '22 at 12:47
  • see my comment above , i removed the `^` in dep. else you can add a dependency overrides key to force firebase to use specific versions https://dart.dev/tools/pub/dependencies#dependency-overrides – griffins Oct 21 '22 at 12:53
  • @griffins I'll give it a shot. What does ^ do really? Is it more like "use this version or any newer"? Something like that? So by removing ^ you lock it basically? – Robert Benedetto Oct 21 '22 at 13:01
  • more like use higher than this where possible – griffins Oct 21 '22 at 13:05
  • I've had this happen to me. What I've done is switch into the android directory and then call ,/gradlew clean and then try calling flutter run from the parent directory again – Alexander N. Oct 21 '22 at 13:08
  • @AlexanderN. You are using Visual Studio Code as well? That command works there? – Robert Benedetto Oct 21 '22 at 13:15
  • Yes, I've run flutter run prior and it caches the gradle wrapper when running. So as long as you have had a gradle build started, it should work – Alexander N. Oct 21 '22 at 13:18

0 Answers0