Flutter/Dart - FlutterFirebaseMessagingPlugin.java - Build fails with Exception "error: cannot find symbol"
Solution 1
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
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
Solution 3
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
They both should be the same.
Meggy
I'm a self-taught novice stumbling like a drunk through php, javascript, mysql, drupal and flutter.
Updated on December 29, 2022Comments
-
Meggy 10 months
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
-
Meggy over 2 yearsI'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.
-
Meggy over 2 yearsWhen 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
-
Meggy over 2 yearsI 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
-
Meggy over 2 yearsSeems 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"
-
Sn1cKa over 2 yearsDid you try to override dependency in your project pubspec.yaml?
-
Meggy over 2 yearsThe fork I created doesn't download anything into External Libraries/Dart Packages even though it doesn't return an error when I do a pub get for pubspec.yaml
-
Meggy over 2 yearsIt's not possible to override the dependency in pubspec.yaml because the Firebase messaging dependencies exist not in my pubspec.yaml but the pubspec.yaml of the FCMConfig project/repository.
-
Meggy over 2 yearsTurns out the plugin creator/maintainer has just updated the plugin.
-
ali sampson about 2 yearsThis worked for me.. thanks sir. At first I was using firebase_messaging: in pubspec.aml file but it was throwing this error. But after adding the latest version number to it, it worked, firebase_messaging: ^10.0.6