简体   繁体   English

没有创建 Firebase App '[DEFAULT]' - 尽管正在初始化 Firebase,但调用 Firebase.initializeApp())

[英]No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()) although Firebase is being initialized

I have a firebase_service.dart file when I create references to all my services.当我创建对所有服务的引用时,我有一个 firebase_service.dart 文件。 The code for that is here代码在这里

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_storage/firebase_storage.dart';

class FirebaseService {
  FirebaseAuth _auth = FirebaseAuth.instance;
  FirebaseStorage _storage = FirebaseStorage.instance;
  FirebaseFirestore _db = FirebaseFirestore.instance;
  FirebaseService();
}

However I receive this error - Exception has occurred.但是我收到此错误 -发生异常。 FirebaseException ([core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp()) FirebaseException([core/no-app] No Firebase App '[DEFAULT]' 已创建 - 调用 Firebase.initializeApp())

In my main.dart file I have initialized firebase as seen below在我的 main.dart 文件中,我已经初始化了 firebase,如下所示

void main() async {
  WidgetsFlutterBinding.ensureInitialized(); //Ensures app is initialized first
  await Firebase.initializeApp; 
  GetIt.instance.registerSingleton<FirebaseService>(
    FirebaseService(),
  );
  runApp(const MyApp());
}

However I am seeing a squiggly line under the await keyword and this is the comment - 'await' applied to 'Future Function({String? name, FirebaseOptions? options})', which is not a 'Future'但是,我在 await 关键字下看到一条波浪线,这是评论 - “await”应用于“Future Function({String? name, FirebaseOptions? options})”,这不是“Future”

Could that be the issue?这可能是问题所在吗? I am not so sure what is wrong here我不太确定这里出了什么问题

I got same problem.我有同样的问题。 My Android application is working fine but when using IOS application it's throw this type of exception.我的 Android 应用程序运行良好,但在使用 IOS 应用程序时会抛出此类异常。 make sure you have added GoogleServices-info.plist file in your ios project and google-service.json android folder.确保您已在 ios 项目和 google-service.json android 文件夹中添加了 GoogleServices-info.plist 文件。 If it's not solve your issue then use this code.如果它不能解决您的问题,请使用此代码。 Also make sure you have configure Android project as per documentation.还要确保您已按照文档配置 Android 项目。 You have to add dependency in build.gradle.(When you add app in firebase you will get instruction).您必须在 build.gradle 中添加依赖。(当您在 firebase 中添加应用程序时,您将获得说明)。 if all above change not working then in your main.dart如果以上所有更改都不起作用,那么在您的 main.dart 中

if (Platform.isIOS) {
    await Firebase.initializeApp(
        options: FirebaseOptions(
            apiKey: "your api key Found in GoogleService-info.plist",
            appId: "Your app id found in Firebase",
            messagingSenderId: "Your Sender id found in Firebase",
            projectId: "Your Project id found in Firebase"));
  } else {
    await Firebase.initializeApp();
  }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有创建 Firebase App - 调用 Firebase.initializeApp() - No Firebase App has been created - call Firebase.initializeApp() 没有创建 Firebase App '[DEFAULT]' - 在 Flutter 和 Firebase 调用 Firebase.initializeApp() - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter and Firebase 没有创建 Firebase App '[DEFAULT]' - 调用 Firebase.initializeApp() -Flutter - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() -Flutter 没有 Firebase 应用程序“[DEFAULT]”已创建 - 在 Flutter 中调用 Firebase.initializeApp() - No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() in Flutter React Native 错误:没有创建 Firebase App '[DEFAULT]' - 调用 firebase.initializeApp() - React Native Error: No Firebase App '[DEFAULT]' has been created - call firebase.initializeApp() Firebase 构建消费者异常<usermanager> // [core/no-app] 没有创建 Firebase App '[DEFAULT]' - 调用 Firebase.initializeApp()</usermanager> - Firebase Exception building a Consumer<UserManager> // [core/no-app] No Firebase App '[DEFAULT]' has been created - call Firebase.initializeApp() 没有 Firebase 应用程序“[DEFAULT]”已创建 - 调用 Firebase App.initializeApp() - Firebase 存储 - No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() - Firebase Storage Flutter Web - No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) - Flutter Web - No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app) 错误:没有 Firebase 应用程序“[DEFAULT]”已创建 - 调用 Firebase App.initializeApp() - Error: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() FirebaseError: Firebase: 否 Firebase App '[DEFAULT]' 已创建 - 调用 Firebase App.initializeApp() {颤动网络} - FirebaseError: Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app). {Flutter web}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM