【问题标题】:Firebase Auth causing Flutter app to crashFirebase Auth 导致 Flutter 应用崩溃
【发布时间】:2020-04-05 22:59:52
【问题描述】:

我刚刚启动了一个新的 Flutter 应用程序,所以还没有真正做任何事情。我将firebase_core: 添加到我的pubspec.yaml 文件中,没有错误并且应用程序启动正常。当我添加 firebase_auth: 它给了我这个错误:

Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Xcode build done.                                           21.9s
    path: satisfied (Path is satisfied), interface: en0
Configuring the default Firebase app...
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23e3dcce __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff50b3b9b2 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff23e3db0c +[NSException raise:format:] + 188
    3   Runner                              0x0000000109e60912 +[FIRApp configure] + 130
    4   Runner                              0x0000000109f2fcd9 -[FLTFirebaseAuthPlugin init] + 217
    5   Runner                              0x0000000109f2fa9b +[FLTFirebaseAuthPlugin registerWithRegistrar:] + 171
    6   Runner                              0x0000000109dfbc13 +[GeneratedPluginRegistrant registerWithRegistry:] + 115
    7   Runner                            <…>
Exited

我已经做到了这一点,并且这个软件包还有许多其他问题。发生了什么?

【问题讨论】:

  • 你运行过flutter包吗?您是否查看了软件包的 README 以了解如何链接软件包?

标签: firebase flutter firebase-authentication


【解决方案1】:

我想你忘记了这里的最后 (7) 步: https://pub.dev/packages/google_sign_in#ios-integration

您必须在 Info.plist 中为每个登录方法添加 CFBundleTypeRoles。 此示例适用于 Google 登录。

<!-- Put me in the [my_project]/ios/Runner/Info.plist file -->
<!-- Google Sign-in Section -->
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <!-- TODO Replace this value: -->
            <!-- Copied from GoogleService-Info.plist key REVERSED_CLIENT_ID -->
            <string>com.googleusercontent.apps.861823949799-vc35cprkp249096uujjn0vvnmcvjppkn</string>
        </array>
    </dict>
</array>
<!-- End of the Google Sign-in Section -->

使用您的 GoogleService-Info.plist 中的那个更改 REVERSED_CLIENT_ID

我家这对你有帮助。我有同样的错误,这是修复。

【讨论】:

    【解决方案2】:

    如果您已将 firebase 包添加到 Flutter 项目中,则应将您从 firebase 控制台下载的 GoogleService-Info.plist 添加到您的 Xcode 项目中。还要确保您的bundle id (com.companyname.appname) 和您的firebase iOS project bundle id 相同。

    请查看此链接以了解 Firebase Flutter 设置:https://firebase.google.com/docs/flutter/setup

    【讨论】:

      【解决方案3】:

      在我的例子中,我在我的颤振应用程序中使用谷歌登录和后台服务。在谷歌登录之前初始化后台服务使我的应用程序崩溃并在初始化后台服务之前进行谷歌登录很好。 如果有人同时使用两者,请考虑这一点。

      【讨论】:

        猜你喜欢
        • 2022-01-21
        • 1970-01-01
        • 1970-01-01
        • 2020-07-26
        • 2019-05-15
        • 2019-05-02
        • 2018-02-11
        • 2017-01-16
        • 2018-09-23
        相关资源
        最近更新 更多