skip to Main Content
  ''' 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 doctor -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

I started getting this error after updating flutter

2

Answers


  1. The old way deprecated:

    await Firebase.initializeApp(); 
    

    It no longer works following this guide from Official Firebase Website.
    and also:

    1. Remove firebase_core from pubspec.yaml.
    2. Run flutter pub add firebase_core in your terminal.
    3. Run flutter pub get
    Login or Signup to reply.
  2. User FlutterFire CLI

    Install the CLI if not already done so via this command

    dart pub global activate flutterfire_cli

    Run the configure command, select a Firebase project and platforms via this command

    flutterfire configure

    import 'package:firebase_core/firebase_core.dart';
    import 'firebase_options.dart';
    
    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp(
        options: DefaultFirebaseOptions.currentPlatform,
      );
      runApp(MyApp());
    }
    

    Also in ios update
    AppDelegate.swift

    import UIKit
    import Flutter
    import Firebase
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
    
    
     FirebaseApp.configure()
     GeneratedPluginRegistrant.register(with: self)
        if #available(iOS 10.0, *) {
          UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
        }
           
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search