Flutter Firebase未正确初始化



我想在我的应用程序中使用firebase,我写这个:

main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(Myapp());
}

但我得到了错误:

I/ExoPlayerImpl( 5331): Init ba5fb7d [ExoPlayerLib/2.17.0] [generic_x86, Android SDK built for x86, unknown, 30]
E/flutter ( 5331): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [core/not-initialized] Firebase has not been correctly initialized.
E/flutter ( 5331): 
E/flutter ( 5331): Usually this means you've attempted to use a Firebase service before calling `Firebase.initializeApp`.
E/flutter ( 5331): 
E/flutter ( 5331): View the documentation for more information: https://firebase.flutter.dev/docs/overview#initialization
E/flutter ( 5331):     
E/flutter ( 5331): #0      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:99:9)
E/flutter ( 5331): <asynchronous suspension>
E/flutter ( 5331): #1      Firebase.initializeApp (package:firebase_core/src/firebase.dart:42:31)

这个:

[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()

我该怎么解决?

有人能帮我吗?

如果用以下内容替换initializeApp((行,它能解决问题吗?

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

相关内容

  • 没有找到相关文章

最新更新