I'm working on iPhone 12 Pro Max Emulator, macOS Catalina.
I'm getting this error when I try to run the app:
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
Also there is a tip in the console:
Usually this means you've attempted to use a Firebase service before calling Firebase.initializeApp
.
I initialize the Firebase before use it. Like this:
void main() async {
print('-- main');
WidgetsFlutterBinding.ensureInitialized();
print('-- WidgetsFlutterBinding.ensureInitialized');
await Firebase.initializeApp();
print('-- main: Firebase.initializeApp');
runApp(const MyApp());
}
This is what I see in the console output:
Xcode build done. 132.9s
flutter: -- main
flutter: -- WidgetsFlutterBinding.ensureInitialized
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
Usually this means you've attempted to use a Firebase service before calling `Firebase.initializeApp`.
I can't see the -- main: Firebase.initializeApp
line in the console. So it fails in first trying to initialize the Firebase.
I create Android/Apple apps in Firebase. Downloaded google-services.json
/ GoogleService-Info.plist
and put in the project.
- GoogleService-Info.plist:
- google-services.json:
I'm not using the android, but I added dependency into build.gradle: classpath 'com.google.gms:google-services:4.3.10'
And app/build.gradle: apply plugin: 'com.google.gms.google-services'
dependencies:
firebase_auth: ^3.3.5
firebase_messaging: ^10.0.9
google_sign_in: ^5.2.1
flutter --version:
Flutter 2.5.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 18116933e7 (3 months ago) • 2021-10-15 10:46:35 -0700
Engine • revision d3ea636dc5
Tools • Dart 2.14.4
How can I solve this problem? BTW, I'm working on a brand new flutter project.
google-services.json
-- did u add it through Xcode? If yes, did you restart your app? – Linhlinimentfirebase_core
to the dependencies. – Linhliniment