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
CodePudding user response:
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
.
CodePudding user response:
Also got it after a pub update. Fixed it by doing:
flutter clean
and removing the pubspec.lock
CodePudding user response:
Problem seems to be with the core platform interface. Add firebase_core_platform_interface: 4.4.0 and adjust all other firebase deps to make them compatible with this library. I downgraded all versions to 36 day old release and it finally works.