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
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"))
}
}
Any ideas?
If Your Flutter Version >= 1.12, then just delete Application.kt and FirebaseCloudMessagingPluginRegistrant.kt if exist. As these additional steps are not required anymore in android. then run
flutter clean
flutter run
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"
......
From official documentation
https://firebase.flutter.dev/docs/messaging/overview#3-android-integration
According to this, if you are using Flutter version 1.12 and high, you require no additional integration inside application.kt. it works out of the box.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With