我的项目突然停止正常运行-无法初始化FirebaseApp.

我一直在使用老式的Firebase配置——直接从Firebase控制台下载谷歌服务文件.我切换到命令flutterfire configure,但错误并没有消失.我还试图删除整个ios目录,并try 再次运行flutterfire configure,但仍然没有结果.

Error:

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(channel-error, Unable to establish connection on channel., null, null)
#0      FirebaseCoreHostApi.initializeCore (package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart:205:7)
<asynchronous suspension>
#1      MethodChannelFirebase._initializeCore (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:29:44)
<asynchronous suspension>
#2      MethodChannelFirebase.initializeApp (package:firebase_core_platform_interface/src/method_channel/method_channel_firebase.dart:73:7)
<asynchronous suspension>
#3      Firebase.initializeApp (package:firebase_core/src/firebase.dart:40:31)
<asynchronous suspension>
#4      main (package:traveler/main.dart:12:3)
<asynchronous suspension>

Line causing the issue:

  // Placed after WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

flutter doctor -v:

[✓] Flutter (Channel master, 3.1.0-0.0.pre.1310, on macOS 12.4 21F79 darwin-arm, locale en-PL)
    • Flutter version 3.1.0-0.0.pre.1310 at /Users/wiktor/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 91603595d1 (13 days ago), 2022-06-18 19:14:07 -0400
    • Engine revision 3ac96a1f40
    • Dart version 2.18.0 (build 2.18.0-190.0.dev)
    • DevTools version 2.14.0

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/wiktor/Library/Android/sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F17a
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] Android Studio
    • Android Studio at /Users/wiktor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.7905991/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] Android Studio
    • Android Studio at /Users/wiktor/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/211.7628.21.2111.7863044/Android Studio Preview.app/Contents
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2)
    • IntelliJ at /Users/wiktor/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
    • Flutter plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      ???? https://plugins.jetbrains.com/plugin/6351-dart

[✓] IntelliJ IDEA Ultimate Edition (version 2021.1.2)
    • IntelliJ at /Users/wiktor/Library/Application Support/JetBrains/Toolbox/apps/IDEA-U/ch-0/211.7442.40/IntelliJ IDEA.app
    • Flutter plugin version 68.1.1
    • Dart plugin version 211.7817

[✓] Connected device (3 available)
    • iPod touch (7th generation) (mobile) • BAEBD16B-8BA9-4D2F-B86D-38282E5FA060 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-5 (simulator)
    • macOS (desktop)                      • macos                                • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)                         • chrome                               • web-javascript • Google Chrome 103.0.5060.53

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

推荐答案

根据@Hardik Mehta分享的this issue,新的SDK不编译,旧的SDK版本不编译.一个对我有效的解决方案是upgrade firebase packages,删除ios/Podfile.lock,然后运行pod install --repo-update.

Ios相关问答推荐

我想在expo 中使用useSafeAreaInsets来获取paddingbottom,但我得到了一个错误

如何在iOS 17 SwiftUI中获取用户名

执行devicectl:ProcessException时出错:进程异常退出:错误:命令超时超过5.0秒

安装新版本 XCode 15.0 后无法运行应用程序 XCode

iphone 11 和 iphone 12 对于相同的布局显示不同的结果

如何在后台显示 Swift UI 中的通讯通知?

AVAudioRecord 没有音频

NavigationLink 只能在文本部分点击

Swift Combine 防止初始值触发接收器并同时防止重复?

如何根据条件快速将返回类型设为 LinearGradient 或 AngularGradient?

如何使用 AppIntents 在 SwiftUI 应用程序中打开特定视图

在 SwiftUI 中将 TextEditor 文本计数连接到 ProgressView

关闭所有打开的视图控制器的单个函数

Xcode 缺少支持文件 iOS 12.2 (16E227)

在 iOS 8 中显示相机权限对话框

如何启用滑动以删除 TableView 中的单元格?

是否可以在 iOS 9 上让您的 iPad 应用退出多任务处理?

在 React Native 中保存敏感数据

如果我的分发证书过期会怎样?

检测应用程序何时进入我的视图背景的最佳方法是什么?