close
[Solved] Flutter/Dart - FlutterFirebaseMessagingPlugin.java - Build fails with Exception “error: cannot find symbol”

[Solved] Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol”

Hello Guys How are you all? Hope You all are fine. When I was trying to run my flutter app and suddenly I get the following error in my stack track. Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” in flutter. So today Here I come with all possible solutions for this error.

We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.

How Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” Error Occurs ?

Today I updated 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:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\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:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\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:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:152: error: cannot find symbol
                      : Metadata.getDefaultSenderId(FirebaseApp.getInstance());
                        ^
      symbol:   variable Metadata
      location: class FlutterFirebaseMessagingPlugin
    C:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:153: error: cannot find symbol
              FirebaseInstanceId.getInstance().deleteToken(senderId, "*");
              ^
      symbol:   variable FirebaseInstanceId
      location: class FlutterFirebaseMessagingPlugin
    C:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:165: error: cannot find symbol
                      : Metadata.getDefaultSenderId(FirebaseApp.getInstance());
                        ^
      symbol:   variable Metadata
      location: class FlutterFirebaseMessagingPlugin
    C:\admin\flutter\.pub-cache\hosted\pub.dartlang.org\firebase_messaging-9.1.4\android\src\main\java\io\admin\flutter\plugins\firebase\messaging\FlutterFirebaseMessagingPlugin.java:166: error: cannot find symbol
              String token = FirebaseInstanceId.getInstance().getToken(senderId, "*");
                             ^
      symbol:   variable FirebaseInstanceId
      location: class FlutterFirebaseMessagingPlugin

Inshort error saying FlutterFirebaseMessagingPlugin.java “cannot find symbol”. So what does this mean and how do I fix it.

How to Solve Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” Error?

Question:
Answer:

  1. How to Solve Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” Error?

    To resolve Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” issue just Open pubspec.yaml file. Get the latest version of firebase_messaging from here. Updated to the latest version. Then flutter pub get. That’s all.

  2. Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol”

    To resolve Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol” issue just Open pubspec.yaml file. Get the latest version of firebase_messaging from here. Updated to the latest version. Then flutter pub get. That’s all.

Solution 1

As I updated my SDK version to null safety all we need to do is just 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

  1. Open pubspec.yaml file.
  2. Get the latest version of firebase_messaging from here.
  3. Updated to latest verison.
  4. Then flutter pub get.
  5. That’s all.

Solution 2

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

Summery

So, It’s All About this error. I hope this tutorial helps you to solve your error. Please Comment Below if You stucks anywhere with my code.

Also Check Out Below Tutorials


Posted

in

by

Comments

One response to “[Solved] Flutter/Dart – FlutterFirebaseMessagingPlugin.java – Build fails with Exception “error: cannot find symbol””

  1. Akyl Avatar
    Akyl

    Very very very thank you bro!

Leave a Reply

Your email address will not be published. Required fields are marked *