【问题标题】:Have you added the "GoogleService-Info.plist" file to the project? --- Firebase with Flutter and Visual Studio code您是否已将“GoogleService-Info.plist”文件添加到项目中? --- 带有 Flutter 和 Visual Studio 代码的 Firebase
【发布时间】:2021-09-01 13:47:56
【问题描述】:

我安装了 XCode,因为颤振医生需要它,但我没有使用它。

我正在使用 VSCode。
在 VSCode 中,我应该将这个名为 GoogleService-Info.plist 的文件放在哪里?

该项目使用 Flutter 和 Firebase。

这是错误:

Exception has occurred. FirebaseException ([core/not-initialized] Firebase has not been correctly initialized. Have you added the "GoogleService-Info.plist" file to the project?

【问题讨论】:

    标签: firebase flutter visual-studio-code


    【解决方案1】:

    在 VSCode 中,按照以下步骤操作

    1. 右键单击ios文件夹
    2. 选择在 Xcode 中打开
    3. 选择Runner > Runner并右击
    4. 选择将文件添加到“Runner”
    5. 选择您的 GoogleService-Info.plist 并按 添加

    并像这样在AppDelegate.swift文件中配置firebase

    import UIKit
    import Flutter
    import Firebase  /// 1. ADD THIS LINE
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        FirebaseApp.configure() /// 2. ADD THIS LINE
        GeneratedPluginRegistrant.register(with: self)
     
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    

    【讨论】:

      【解决方案2】:

      按照documentation 中的以下步骤将GoogleService-Info.plist 文件添加到项目中:

      1. 使用 Xcode 打开项目的 ios/{projectName}.xcworkspace 文件。右键单击左侧项目导航中的 Runner 在 Xcode 中并选择“添加文件”。
      2. 选择您下载的 GoogleService-Info.plist 文件,并确保“如果需要,复制项目”复选框已启用。

      【讨论】:

        【解决方案3】:

        转到您的“projectName”>android>应用程序并将文件转储到此目录中。

        【讨论】:

          猜你喜欢
          • 2021-06-08
          • 2021-02-02
          • 1970-01-01
          • 2018-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-12-08
          • 1970-01-01
          相关资源
          最近更新 更多