Flutter Firebase尚未正确初始化

发布于 2025-01-18 21:49:14 字数 1319 浏览 3 评论 0原文

我想在我的应用中使用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()

如何解决?

有人可以帮我吗?

I want to use firebase in my app,
I write this:

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

but I got error :

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)

and this:

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

how can I solve it?

can anyone help me, please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小霸王臭丫头 2025-01-25 21:49:14

如果您用以下内容替换initializeapp()行,是否可以解决问题?

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

Does it solve the issue if you replace the initializeApp() line with the following?

await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文