flutterfirebase

Calling Firebase.initializeApp() returns 'Unable to establish connection on channel' - Flutter + Firebase


I'm working with Firebase in flutter (latest versions as of 1st July 2022), and when I try to call Firebase.initializeApp() in my Main function, it returns an error of:

'[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)'

Here is my code:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Firebase.initializeApp();
  runApp(const MyApp());
}

Any help would be greatly appreciated


Solution

  • I was able to solve the problem by upgrading all my firebase dependencies to the latest version using flutter pub outdated and flutter pub upgrade firebase_....

    I encountered this issue after adding the firebase_messaging plugin v11.4.4. Might be related to the change in firebase_core_platform_interface.