简体   繁体   中英

ERROR : Undefined name 'Firebase' in main.dart

Hello to whom it may concern, I am setting up flutter environment in Android Studio and have searched to resolve this error but couldn't find any solution. The app I am working on has been registered with Firebase and I have copied all the code from flutter repo everything is fine except this one error where the keyword Firebase is not recognized. I have imported the targeted libraries but to no good.

Here is the line of code that has the error in main.dart:

await Firebase.initializeApp();

The error reads "Undefined name 'Firebase'. Try correcting the name to one that is defined, or defining the name"

Your help would mean a lot! Thank you

Looks like you're missing firebase_core for some reason.

Try adding explicitly to your pubspec.yaml and see if it helps.

firebase_core: ^1.0.1

not to use- firebase_core: ^0.4.0+9 to use- firebase_core: ^1.4.0

not to use- firebase_analytics: ^5.0.2 to use- firebase_analytics: ^8.2.0

not to use- firebase_auth: ^0.14.0+5 to use- firebase_auth: ^3.0.1

not to use- cloud_firestore: ^0.12.9+5 to use- cloud_firestore: ^2.4.0

changing versions helped me...... dont use versions mentioned on firebase documentation, use it from pub.dev

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM