【问题标题】:iOS: MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core)iOS:MissingPluginException(在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的实现)
【发布时间】:2022-01-21 04:51:19
【问题描述】:

我在 iOS 上构建 Flutter 应用时遇到了这个错误(它在 Android 上运行良好):

MissingPluginException (MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core))

我在这个论坛的几个地方搜索并看到了这个错误,但解决方案都是针对 Android 的,而不是针对 iOS 的。我很茫然。

这是我的 pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  firebase_core: ^1.10.0
  firebase_database: ^9.0.4
  firebase_analytics: ^9.0.4
  cloud_firestore: ^3.1.1
  flutter_gallery_assets: ^1.0.2
  firebase_storage: ^10.2.0  
  permission_handler: ^8.3.0
  cupertino_icons: ^1.0.4
  flutter_cupertino_localizations: ^1.0.1
  http: ^0.13.4
  get_it: ^7.2.0
  provider: ^6.0.1
  flappy_search_bar: ^1.7.2
  flutter_form_builder: ^7.0.0
  image_picker: ^0.8.4+4
  camera: ^0.9.4+5
  path_provider: ^2.0.7
  path: 


dev_dependencies:
  flutter_test:
    sdk: flutter
grinder: ^0.8.4

我运行过flutter doctorflutter cleanflutter pub get。我已删除并重新安装了该应用程序。我将 Firebase 更新到了最新版本。

这里是我调用 Firebase 的地方以及弹出错误的地方:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp();

  runApp(MaterialApp(
      title: "Using Tabs",
      home: MyHome()));
}

为了好玩,我也在 build.gradle 中实现了这个解决方案,虽然它似乎是特定于 Android 的,而不是 iOS:

buildTypes {       
    release {
        signingConfig signingConfigs.release
        minifyEnabled false
        shrinkResources false
    }
}

如果有人有任何想法,非常感谢。谢谢!

【问题讨论】:

    标签: ios firebase flutter


    【解决方案1】:

    您是否在 AppDelegate 中正确注册 GeneratedPluginRegistrant ?
    由于 Firebase 使用了一些原生平台调用,因此需要此行。

    import UIKit
    import Flutter
    import Firebase
    import FlutterPluginRegistrant
    
    
    @UIApplicationMain
    class AppDelegate: FlutterAppDelegate {
    
         var flutterEngine : FlutterEngine?
    
         override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
             // Instantiate Flutter engine
             self.flutterEngine = FlutterEngine(name: "fullScreenEngineId")
             self.flutterEngine?.run()
             GeneratedPluginRegistrant.register(with: self.flutterEngine!)
    
             return super.application(application, didFinishLaunchingWithOptions: launchOptions) 
         }
    
    }
    
    
    

    【讨论】:

      猜你喜欢
      • 2021-11-03
      • 2021-05-28
      • 2022-01-05
      • 2021-05-21
      • 2022-01-25
      • 2021-12-31
      • 2021-12-24
      • 2020-07-21
      相关资源
      最近更新 更多