本文介绍了Application.kt:未解决的参考:firebasemessaging的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 firebase_messaging 更新到新版本 8.0.0-dev.10 .

I am trying to update firebase_messaging to the new version 8.0.0-dev.10.

但是,我遇到了这些错误:

However, I am getting these errors:

Running Gradle task 'assembleDebug'...
Application.kt: (5, 27): Unresolved reference: firebasemessaging
Application.kt: (6, 27): Unresolved reference: firebasemessaging
Application.kt: (11, 9): Unresolved reference: FlutterFirebaseMessagingService
Application.kt: (15, 9): Unresolved reference: FirebaseMessagingPlugin

这是我的Application.kt的样子

This is what my Application.kt looks like

package com.example.opengames

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService

class Application : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
    override fun onCreate() {
        super.onCreate()
        FlutterFirebaseMessagingService.setPluginRegistrant(this);
    }

    override fun registerWith(registry: PluginRegistry?) {
        FirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"))
    }
}

有什么想法吗?

推荐答案

您可以按以下步骤进行修复,创建 Application.kt 文件

You can fix it as follows, create the Application.kt file

package com.example.YOUR.PACKAGE

import io.flutter.app.FlutterApplication
import io.flutter.plugin.common.PluginRegistry

import io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin

class Application() : FlutterApplication(), PluginRegistry.PluginRegistrantCallback {
  override fun registerWith(registry: PluginRegistry?) {
      val key: String? = FlutterFirebaseMessagingPlugin::class.java.canonicalName
      if (!registry?.hasPlugin(key)!!) {
          FlutterFirebaseMessagingPlugin.registerWith(registry?.registrarFor("io.flutter.plugins.firebase.messaging.FlutterFirebaseMessagingPlugin"));
        }
    }
}

,然后在清单中更改为:

and in your Manifest change to:

 <application
        android:label="El Chaski Customer"
        android:name=".Application"
        android:icon="@mipmap/launcher_icon">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
......

这篇关于Application.kt:未解决的参考:firebasemessaging的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 23:22