Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter/Dart - FlutterFirebaseMessagingPlugin.java - Build fails with Exception "error: cannot find symbol"

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

like image 673
Meggy Avatar asked May 20 '21 07:05

Meggy


2 Answers

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

like image 72
Sn1cKa Avatar answered Sep 18 '22 12:09

Sn1cKa


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

like image 36
Harshvardhan R Avatar answered Sep 21 '22 12:09

Harshvardhan R