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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
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 Comments

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
Remove your pubspec.lock file and try running flutter pub get again.
@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
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]
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.