0

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

3 Answers 3

1

Did you try importing firebase_core in main.dart import 'package:firebase_core/firebase_core.dart';

1
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Apr 14, 2022 at 2:42
0

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
4
  • I have added the dependencies previously. Here's what pubspec.yaml file dependencies states: 'dependencies: flutter: sdk: flutter # Add the dependency for the Firebase Core Flutter SDK firebase_core: ^0.4.0+5 firebase_analytics: ^5.0.2 Commented Mar 10, 2021 at 15:49
  • Remove your pubspec.lock file and try running flutter pub get again. Commented Mar 10, 2021 at 16:46
  • @miguel_ruivo Tried that still no luck. If you can kindly check the image since this is the only problem in the entire project structure. Perhaps you can help through this. This is the link pasteboard.co/JS0nQKW.png Commented Mar 10, 2021 at 18:51
  • Tried that still no luck. If you can kindly check the image since this is the only problem in the entire project structure. Perhaps you can help through this. This is the link [pasteboard.co/JS0nQKW.png] Commented Mar 12, 2021 at 13:50
0

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.