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

Android Mohit Mozumder

Problem:

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)'


Solution 1:

You've upgraded Flutter but not the packages.So In the terminal enter

flutter pub outdated

Then upgrade the outdated packages-

flutter upgrade outdated_package

After you're finished give those command:

flutter clean

&

flutter pub get


Solution 2:

First do a  flutter clean and remove the "pubspec.lock". Hope it will work if not follow the next solutions.


Solution 3:

First Do a flutter clean and upgrade firebase core with

flutter pub upgrade firebase_core

Then run

dart pub global activate flutterfire_cli
flutterfire configure

to reinitialize firebase.


Thank you for reading the article. If you face any further problem feel free to ask us.