18

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

3
  • 1
    did you find any solution ? Commented May 21, 2021 at 10:50
  • I tried to fork & clone the project in order to change the outdated dependencies in pubspec.yaml. But this is my first time and I don't understand why "pub get" is not downloading the plugin into my external libraries folder in my Flutter app. Commented May 21, 2021 at 11:01
  • The plugin creator/maintainer has just updated the plugin to veriosn 3.05. Commented May 24, 2021 at 7:22

3 Answers 3

41

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

Sign up to request clarification or add additional context in comments.

9 Comments

I've using the latest fcm_config: 3.0.4 in pubspec.yaml which must have firebase_messaging-9.1.4 bundled in it. But I have no idea how to upgrade it.
When I do a pub outdated I get this as outdated transitive dependencies. But as I said I have no idea how to upgrade it; firebase_messaging *9.1.4 *9.1.4 *9.1.4 10.0.0 firebase_messaging_platform_interface *2.1.4 *2.1.4 *2.1.4 3.0.0 firebase_messaging_web *1.0.7 *1.0.7 *1.0.7 2.0.0
I tried forking the original repository and updating the pubspec.yaml to include the new updated firebase but a "pub get" tells me there's no pubspec.yaml
Seems cloning the repository leaves me one level up from where the pubspec.yaml exists. Any idea how I can point the entry one level up? Here's the entry; fcm_config: git: url: "github.com/meghead/fcm_config.git"
Did you try to override dependency in your project pubspec.yaml?
|
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

Comments

1

For me, the problem was that I updated androidx core version from 1.0.1 to 1.5.0 in my app/gradle file but I didn't update it in project level gradle file in resolutionStrategy

enter image description here

enter image description here

They both should be the same.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.