Unhandled Exception: PlatformException(null-error, Host platform returned null value for non-null return value., null, null)

13.5k views Asked by At

i got this Error i didn't know how i would to solve it any solution Please.

when i initialise firebase im main function it show me this white screnn and flutter icon:

enter image description here

enter image description here

but when i delete this initliation this firebase app run successfully as it is:

enter image description here

and show me those errors

enter image description here

4

There are 4 answers

1
Md. Kamrul Amin On

Make sure you have firebase_core in your pubspec.yaml Then, just use the following in your main:

await Firebase.initializeApp(
  options: DefaultFirebaseOptions.currentPlatform,
);

run

flutter clean

and

flutter pub get

in your terminal.

If it still fails, please go step by step following the firebase documentation. It should work. https://firebase.google.com/docs/flutter/setup?platform=android

1
ahmnouira On

I just forget to add Google services plugin in android/app/build.gradle:

apply plugin: 'com.google.gms.google-services'
0
KTZaw On

For my problem, I solved it by changing firebase initialization in main.dart as followed.

await Firebase.initializeApp(options:DefaultFirebaseOptions.currentPlatform);
0
Manish Sahu On

Above solution didn't work for me.

The problem is that flutter cannot connect to firebase. It can be due to incorrect google-services.json generating or pasting on wrong location.

Firebase has flutter tool to automatically inject the required configs, which actually worked for me.

Prerequisite