【问题标题】:MissingPluginException(No implementation found for method Firebase#initializeCore on channel plugins.flutter.io/firebase_core) on releaseMissingPluginException(在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的实现)在发布时
【发布时间】:2021-05-28 06:02:53
【问题描述】:

我正在使用 Firebase 身份验证构建一个颤振应用。当我在我的 android 模拟器或我的 android 手机上运行 Flutter 进行测试时,该应用程序运行良好,没有出现重大错误。

当我尝试构建 apk 或 appbundle 并且 Firebase.initializeApp() 失败时,就会出现问题。

由于我没有在调试模式下运行,我不确定如何跟踪此错误。

[更新]

我可以跟踪捕获从 Firebase.initializeApp() 抛出的异常的错误,并且是 MissingPluginException(在通道 plugins.flutter.io/firebase_core 上找不到方法 Firebase#initializeCore 的实现)

我仍然不明白为什么这个错误只是在发布时出现,而在调试时运行完美。

这是我的 app/build.gradle sn-p

(...)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

(...)

dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation platform('com.google.firebase:firebase-bom:26.2.0')
    implementation 'com.google.firebase:firebase-dynamic-links'
    implementation 'com.google.firebase:firebase-analytics'
    implementation 'com.google.firebase:firebase-auth'
    implementation 'com.google.firebase:firebase-firestore'
}

还有我的项目 build.gradle 依赖项

(...)

dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.12.9, 0.99.99]'
}

(...)

还有我的 firebase 依赖项

dependencies:
  flutter:
    sdk: flutter
  firebase_core: ^0.7.0
  cloud_firestore: ^0.16.0
  firebase_auth: ^0.20.0+1
  firebase_storage: ^7.0.0

【问题讨论】:

    标签: firebase flutter google-cloud-firestore


    【解决方案1】:

    我遇到了同样的问题,所以我在我的 main.dart 文件中添加了这段代码,它对我有用。它的作用是如果Firebase.intitalizeApp() 失败,那么它将显示我创建的errorPage,如果它加载,那么它可以显示应用程序主页,如果它仍在加载,那么它会显示一个加载页面。这是它的代码。希望它可以帮助你为我工作。

      @override
      Widget build(BuildContext context) {
        return FutureBuilder(
          // Initialize FlutterFire
          future: Firebase.initializeApp(),
          builder: (context, snapshot) {
    
            // Check for errors
            if (snapshot.hasError) {
              return SomethingWentWrong();
            }
    
            // Show Application
            if (snapshot.connectionState == ConnectionState.done) {
              return StreamProvider<Help4YouUser>.value(
                value: AuthService().user,
                child: MaterialApp(
                  debugShowCheckedModeBanner: false,
                  home: Wrapper(),
                ),
              );
            }
    
            // Initialization
            return PouringHourGlassPageLoad();
          },
        );
      }
    

    【讨论】:

    • 感谢您的回复,但我认为您的解决方案只是处理显示错误页面的错误,之后您如何超越此启动页面?我认为问题仍然存在于与 firebase 的连接中
    • @LeonardoUgiete 您可以在错误页面中添加一个刷新按钮,如果单击它将重新启动应用程序,并且它将重试初始化firebase。这可能有效
    猜你喜欢
    • 2021-11-03
    • 2022-01-05
    • 2022-01-21
    • 2022-01-25
    • 2021-12-31
    • 2020-07-21
    • 2021-05-21
    • 2021-12-24
    相关资源
    最近更新 更多