After upgrading to Null Safety sdk: ">=2.12.0 <3.0.0"
I'm getting errors when I try to build my Flutter app in Android Studio.
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:20: error: cannot find symbol
import com.google.firebase.iid.FirebaseInstanceId;
^
symbol: class FirebaseInstanceId
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:21: error: cannot find symbol
import com.google.firebase.iid.Metadata;
^
symbol: class Metadata
location: package com.google.firebase.iid
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:152: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:153: error: cannot find symbol
FirebaseInstanceId.getInstance().deleteToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:165: error: cannot find symbol
: Metadata.getDefaultSenderId(FirebaseApp.getInstance());
^
symbol: variable Metadata
location: class FlutterFirebaseMessagingPlugin
C:\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol
String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
^
symbol: variable FirebaseInstanceId
location: class FlutterFirebaseMessagingPlugin
Android Studio tells me FlutterFirebaseMessagingPlugin.java "cannot find symbol". So what does this mean and how do I fix it
Update your firebase_messaging
in pusbpec.yaml to version that supports null-safety (for example: firebase_messaging: ^10.0.0
, and call flutter pub get from
terminal
First, get the latest versions of your firebase dependencies from pub.dev
Run the commands:
flutter pub upgrade
flutter pub get
flutter clean
Invalidate caches and restart
and then try running the app
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