Flutter使用直接Dart Firebase初始化在真实设备上仍会出现错误:“无法找到配置文件:'GoogleService-Info.plist'”。

6
Flutter 2.8.1使用flutterfire - 根据文档,不需要使用GoogleService-Info.plist文件。此版本支持直接dart初始化。在模拟器上可以正常工作,但在真实的iOS设备上运行时 - 无论是从Android Studio还是XCode中运行,都会出现有关plist文件的错误。flutterfire configure创建有效的firebase_options.dart文件,主要如下:
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(const MyApp());
}

flutter doctor的输出结果:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.8.1, on macOS 12.0.1 21A559 darwin-x64, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.63.2)
[✓] Connected device (3 available)

你有找到任何解决这个问题的方法吗?所以Dart的初始化在iOS上不起作用?我刚刚做了这个 - https://firebase.flutter.dev/docs/manual-installation#ios 我的Firebase初始化失败,因为它找不到GoogleServices-info.plist文件。有什么提示可以修复吗? - Krishna Shetty
2个回答

1

0

你在 XCode 中是否已添加 GoogleServices-info.plist 文件?

我的意思是,你是否已经从 Finder 拖放它到 Android Studio 或 XCode 中。

你需要将它拖放到 XCode 中。


6
没有做过这个。我知道过去这是必须的步骤,但根据flutterfire文档,这一步现在不再需要,因为该框架现在支持直接的Dart初始化。正如我上面提到的,直接的Dart初始化在模拟器中是可行的。我能够连接到Firebase数据库,执行身份验证活动等等。所有这些都不需要plist文件。但在真实设备上却无法运行。 - sstakoff
那我不知道。 - liam spiegel
没问题 - 感谢你的尝试! - sstakoff
1
我也遇到了同样的问题。在真实设备上运行失败,但在模拟器中却可以正常运行。如果您最终解决了这个问题,请告诉我一声。 - Anthony Castelli
我可以帮助你,但我需要更多的信息。我知道它与FlutterFire有关,但这就是我所知道的全部。因此,请您提供更多信息,例如在真机上运行时出现的完整错误信息。 - liam spiegel
显示剩余2条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接