firebase核心初始化错误我在更新flutter后开始得到这个错误

j5fpnvbx  于 2023-03-03  发布在  Flutter
关注(0)|答案(1)|浏览(435)
''' Launching lib/main.dart on sdk gphone64 arm64 in debug mode...
    : Error: The method 'initializeCore' isn't defined for the class 'FirebaseCoreHostApi'.
    - 'FirebaseCoreHostApi' is from 'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart' ('../../.pub-cache/hosted/pub.dev/firebase_core_platform_interface-4.5.3/lib/src/pigeon/messages.pigeon.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'initializeCore'.
        List<PigeonInitializeResponse?> apps = await api.initializeCore();
                                                         ^^^^^^^^^^^^^^
: Error: The method 'optionsFromResource' isn't defined for the class 'FirebaseCoreHostApi'.

- 'FirebaseCoreHostApi' is from 'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart' ('../../.pub-cache/hosted/pub.dev/firebase_core_platform_interface-4.5.3/lib/src/pigeon/messages.pigeon.dart').
Try correcting the name to the name of an existing method, or defining a method named 'optionsFromResource'.
        final options = await api.optionsFromResource();
                                  ^^^^^^^^^^^^^^^^^^^

: Error: Undefined name '_binaryMessenger'.
      binaryMessenger: _binaryMessenger);

                       ^^^^^^^^^^^^^^^^
: Error: Undefined name 'codec'.

      'dev.flutter.pigeon.FirebaseCoreHostApi.initializeCore', codec,
                                                               ^^^^^
: Error: Undefined name '_binaryMessenger'.
      binaryMessenger: _binaryMessenger);
                       ^^^^^^^^^^^^^^^^
: Error: Undefined name 'codec'.
      'dev.flutter.pigeon.FirebaseCoreHostApi.optionsFromResource', codec,
                                                                    ^^^^^

Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

* Where:
Script '/Users/iberkeugur/development/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 1151

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/iberkeugur/development/flutter/bin/flutter'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 3s
Exception: Gradle task assembleDebug failed with exit code 1
Exited

“”“Flutter医生-v

% flutter doctor -v
[✓] Flutter (Channel stable, 3.7.6, on macOS 13.1 22C65 darwin-arm64, locale en-TR)
    • Flutter version 3.7.6 on channel stable at /Users/iberkeugur/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 12cb4eb7a0 (20 hours ago), 2023-03-01 10:29:26 -0800
    • Engine revision ada363ee93
    • Dart version 2.19.3
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/iberkeugur/Library/Android/sdk
    • Platform android-33, build-tools 33.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2021.3)
    • 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.13+0-b1751.21-8125866)

[✓] VS Code (version 1.76.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.60.0

[✓] Connected device (4 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554                        • android-arm64  • Android 13 (API 33) (emulator)
    • iPhone 14 Pro Max (mobile)  • 24497C01-96C2-4084-9240-7FB8838E76E8 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)             • macos                                • darwin-arm64   • macOS 13.1 22C65 darwin-arm64
    • Chrome (web)                • chrome                               • web-javascript • Google Chrome 110.0.5481.177

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

• No issues found!

Pubspec.yaml

environment:
  sdk: '>=2.19.3 <3.0.0'
dependencies:
  cupertino_icons: ^1.0.2
  firebase_core: ^2.7.0
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter

我开始得到这个错误后更新flutter

bejyjqdl

bejyjqdl1#

旧的方法被废弃了:

await Firebase.initializeApp();

它不再工作以下this指南从官方Firebase网站。以及:
1.从pubspec.yaml中删除firebase_core。
1.在你的终端运行flutter pub add firebase_core。
1.跑跑跳跳酒吧

相关问题