I've upgraded all my firebase packages today, and I had to upgrade to version 8.0.0-dev.13 for firebase messaging even though it is still in dev due to dependency issues. In Application.Java, I have:
package com.halloglobal.flutterapp.hallo;
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
import io.flutter.view.FlutterMain;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@override
public void registerWith(PluginRegistry registry) {
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
}
}
Which has worked fine in the past, but now with this new version, I get this error: Note: Recompile with -Xlint:deprecation for details. /Users/hallo/Documents/HalloMonoRepo/hallo/android/app/src/main/java/com/halloglobal/flutterapp/hallo/Application.java:7: error: package io.flutter.plugins.firebasemessaging does not exist import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService; ^ /Users/hallo/Documents/HalloMonoRepo/hallo/android/app/src/main/java/com/halloglobal/flutterapp/hallo/Application.java:8: error: package io.flutter.plugins.firebasemessaging does not exist import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
How do I need to change my Application.java to work with the new version?
I fixed it by removing the plugin registration completely, the new version handles it internally now.
this worked for me. Maybe will help you.if there is something you don't use, remove it like flutter local notification. Also you can check this article https://medium.com/@demmydwirhamadan/working-well-firebase-cloud-messaging-push-notification-in-flutter-tested-on-android-4eb91f45d45
import io.flutter.app.FlutterApplication;
import io.flutter.plugin.common.PluginRegistry;
import io.flutter.plugin.common.PluginRegistry.PluginRegistrantCallback;
import io.flutter.plugins.GeneratedPluginRegistrant;
import com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin;
import io.flutter.plugins.firebasemessaging.FlutterFirebaseMessagingService;
import io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin;
public class Application extends FlutterApplication implements PluginRegistrantCallback {
@Override
public void onCreate() {
super.onCreate();
FlutterFirebaseMessagingService.setPluginRegistrant(this);
}
@Override
public void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
FirebaseMessagingPlugin.registerWith(registry.registrarFor("io.flutter.plugins.firebasemessaging.FirebaseMessagingPlugin"));
FlutterLocalNotificationsPlugin.registerWith(registry.registrarFor("com.dexterous.flutterlocalnotifications.FlutterLocalNotificationsPlugin"));
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = Application.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}
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