[firebase_messaging]: 16.4.2 fails to compile, FirebasePlugin type not found in any published firebase_core_platform_interface
Is there an existing issue for this?
- [x] I have searched the existing issues.
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
firebase_messaging 16.4.2 does not compile. FirebaseMessaging extends a base class named FirebasePlugin, but no published firebase_core_platform_interface defines that type. Any resolve that lands on 16.4.2 fails at build time:
firebase_messaging-16.4.2/lib/src/messaging.dart:11:33: Error: Type 'FirebasePlugin' not found.
class FirebaseMessaging extends FirebasePlugin {
^^^^^^^^^^^^^^
firebase_messaging-16.4.2/lib/src/messaging.dart:21:36: Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'.
app: app, pluginConstants: pluginConstants);
^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
What changed between 16.4.1 and 16.4.2:
16.4.1: class FirebaseMessaging extends FirebasePluginPlatform // compiles
16.4.2: class FirebaseMessaging extends FirebasePlugin // does not compile
firebase_messaging.dart pulls FirebasePlugin via show FirebasePlugin from firebase_core_platform_interface, but:
firebase_core_platform_interfacelatest is 7.1.0, and it defines onlyFirebasePluginPlatform(extendsPlatformInterface). No published version definesFirebasePlugin.firebase_core4.12.0, which is 16.4.2's declared minimum, exports no DartFirebasePlugineither.- 16.4.2 constrains
firebase_core_platform_interface: ^7.1.0, which resolves to 7.1.0 and lacks the symbol.
It looks like the FirebasePluginPlatform to FirebasePlugin rename shipped in the 16.4.2 publish, but the matching firebase_core_platform_interface release that actually defines FirebasePlugin was never published, or the constraint was not bumped to require it. 16.4.1 still extends FirebasePluginPlatform and compiles fine.
Reproducing the issue
- Use any pubspec whose version range admits firebase_messaging 16.4.2.
- Run
flutter pub get. It resolves firebase_messaging 16.4.2, firebase_core 4.12.0, firebase_core_platform_interface 7.1.0. - Run
flutter buildfor any target. Compilation fails with the errors above.
Workaround: pin firebase_messaging: 16.4.1.
Firebase Core version
4.12.0
Flutter Version
3.44.5 (stable), Dart 3.12.2
Relevant Log Output
firebase_messaging-16.4.2/lib/src/messaging.dart:11:33: Error: Type 'FirebasePlugin' not found.
class FirebaseMessaging extends FirebasePlugin {
^^^^^^^^^^^^^^
firebase_messaging-16.4.2/lib/src/messaging.dart:21:36: Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'.
- 'FirebaseMessaging' is from 'package:firebase_messaging/firebase_messaging.dart'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'pluginConstants'.
app: app, pluginConstants: pluginConstants);
^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
Flutter dependencies
Expand Flutter dependencies snippet
firebase_core 4.12.0
firebase_core_platform_interface 7.1.0
firebase_core_web 3.9.0
firebase_messaging 16.4.2
firebase_messaging_platform_interface 4.9.1
firebase_messaging_web 4.2.2
Additional context and comments
No response
I agree, firebase_messaging 16.4.2 is a broken upstream publish
I am seeing the same issue, can confirm.
Having the same issue.
idem
All flutterfire packages published today are broken.
../../../../.pub-cache/hosted/pub.dev/firebase_messaging-16.4.2/lib/src/messaging.dart:11:33: Error: Type 'FirebasePlugin' not found.
class FirebaseMessaging extends FirebasePlugin {
^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/firebase_analytics-12.4.4/lib/src/firebase_analytics.dart:8:33: Error: Type 'FirebasePlugin' not found.
class FirebaseAnalytics extends FirebasePlugin {
^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/firebase_crashlytics-5.2.5/lib/src/firebase_crashlytics.dart:11:35: Error: Type 'FirebasePlugin' not found.
class FirebaseCrashlytics extends FirebasePlugin {
^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/firebase_messaging-16.4.2/lib/src/messaging.dart:21:36: Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'.
- 'FirebaseMessaging' is from 'package:firebase_messaging/firebase_messaging.dart' ('../../../../.pub-cache/hosted/pub.dev/firebase_messaging-16.4.2/lib/firebase_messaging.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'pluginConstants'.
app: app, pluginConstants: pluginConstants);
^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/firebase_crashlytics-5.2.5/lib/src/firebase_crashlytics.dart:25:36: Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseCrashlytics'.
- 'FirebaseCrashlytics' is from 'package:firebase_crashlytics/firebase_crashlytics.dart' ('../../../../.pub-cache/hosted/pub.dev/firebase_crashlytics-5.2.5/lib/firebase_crashlytics.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'pluginConstants'.
app: app, pluginConstants: pluginConstants);
^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
same issue with 16.4.2 on windows: /Local/Pub/Cache/hosted/pub.dev/firebase_messaging-16.4.2/lib/src/messaging.dart(21,36): error G4127D1E8: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'
I've had the same issue. I was able to get around this by pinning firebase_core to 4.11.0
firebase_core: 4.11.0
Google can have such serious problems?
The only option is to revert to the previous version.
firebase_core: ^4.12.0
firebase_messaging: 16.4.1
firebase_analytics: 12.4.3
firebase_crashlytics: 5.2.4
quite annoying that these people work in good environment and forget to do basic things such as publishing a pub package.
anyways you could get over it by resolving to the git version, it's up to date but the pub version isn't
dependency_overrides:
firebase_core_platform_interface:
git:
url: https://github.com/firebase/flutterfire.git
path: packages/firebase_core/firebase_core_platform_interface
use firebase_messaging: 16.4.1
Is not only messagin is remote config and app check too
I don't know how so many users had been this issue in a simple flutter pub get + flutter run and Firebase team couldn't catch it.
Seems too much focus on AI for too poor quality for existent products.
I've found same problem and revert to previous version Google ai ai ai ai...
same issue with 16.4.2 on macOS: .... /hosted/pub.dev/firebase_messaging-16.4.2/lib/src/messaging.dart(21,36): The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'
Hi all, thanks for the report. I'm taking a look.
until the firebase_core_platform_interface issue is officially patched, if you are stuck constantly running flutter clean and pub cache clean, just remove the ^ from your versions, run a clean cache, and do the rest.
Fixing Type 'FirebasePlugin' not found — with Code
1. The Error
firebase_messaging-16.4.2/lib/src/messaging.dart:11:33: Error: Type 'FirebasePlugin' not found.
class FirebaseMessaging extends FirebasePlugin {
^^^^^^^^^^^^^^
firebase_messaging-16.4.2/lib/src/messaging.dart:21:36: Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'.
app: app, pluginConstants: pluginConstants);
^^^^^^^^^^^^^^^
Target kernel_snapshot_program failed: Exception
2. The Failing Code (consumer side)
firebase_messaging-16.4.2/lib/src/messaging.dart does roughly this:
import 'package:firebase_core_platform_interface/firebase_core_platform_interface.dart';
class FirebaseMessaging extends FirebasePlugin {
FirebaseMessaging._({required this.app})
: super(app.name, 'plugins.flutter.io/firebase_messaging');
final FirebaseApp app;
Map<dynamic, dynamic> _getPluginConstants() {
// pluginConstants is inherited from FirebasePlugin
return MessagingPigeonFirebaseApp(
app: app, pluginConstants: pluginConstants);
}
}
It depends on a class literally named FirebasePlugin existing in
firebase_core_platform_interface, with a pluginConstants getter on it.
3. What Actually Exists Upstream
In current firebase_core_platform_interface, the base class was renamed to
FirebasePluginPlatform:
// platform_interface_firebase_plugin.dart
abstract class FirebasePluginPlatform extends PlatformInterface {
FirebasePluginPlatform(this._appName, this._methodChannelName)
: super(token: _token);
static Map<dynamic, dynamic> _constantsForPluginApps = {};
final String _appName;
final String _methodChannelName;
static final Object _token = Object();
static void verify(FirebasePluginPlatform instance) {
PlatformInterface.verify(instance, _token);
}
/// Returns any plugin constants this plugin app instance has initialized.
Map<dynamic, dynamic> get pluginConstants {
final appConstants =
_constantsForPluginApps[_appName] as Map<Object?, Object?>?;
if (appConstants != null && appConstants[_methodChannelName] != null) {
return appConstants[_methodChannelName]! as Map<dynamic, dynamic>;
}
return {};
}
}
There is no FirebasePlugin class at all — hence:
Error: Type 'FirebasePlugin' not found.
And since FirebaseMessaging fails to resolve its supertype, the compiler
also can't find the inherited pluginConstants getter:
Error: The getter 'pluginConstants' isn't defined for the type 'FirebaseMessaging'.
This is a version-skew bug: the resolved firebase_messaging version
was written for an older API name that no longer exists in the resolved
firebase_core_platform_interface version.
4. The Fix
Add a backwards-compatible typedef in
firebase_core_platform_interface.dart (the main library file):
part 'src/firebase_core_exceptions.dart';
part 'src/firebase_exception.dart';
part 'src/firebase_options.dart';
part 'src/method_channel/method_channel_firebase.dart';
part 'src/method_channel/method_channel_firebase_app.dart';
part 'src/platform_interface/platform_interface_firebase.dart';
part 'src/platform_interface/platform_interface_firebase_app.dart';
part 'src/platform_interface/platform_interface_firebase_plugin.dart';
/// The default Firebase application name.
const String defaultFirebaseAppName = '[DEFAULT]';
/// Backwards-compatible name expected by current firebase_messaging releases.
typedef FirebasePlugin = FirebasePluginPlatform;
That single line is the entire fix:
typedef FirebasePlugin = FirebasePluginPlatform;
Why this works
A typedef creates an alias, not a new type. After this line:
class FirebaseMessaging extends FirebasePlugin { // resolves to FirebasePluginPlatform
...
pluginConstants // now found, inherited from FirebasePluginPlatform
}
compiles cleanly again, because FirebasePlugin is FirebasePluginPlatform
as far as the type system is concerned — same class, same members, same
pluginConstants getter.
5. Before / After Summary
| Before fix | After fix | |
|---|---|---|
| FirebasePlugin exists? | ❌ No (renamed to FirebasePluginPlatform) | ✅ Yes (as a typedef alias) |
| firebase_messaging 16.4.2 compiles? | ❌ No | ✅ Yes |
| Plugins already using FirebasePluginPlatform? | Unaffected | Still unaffected |
| Breaking change introduced? | — | None |
6. General Takeaway
If you see Type 'X' not found after a pub upgrade/pub get, it's almost
always a renamed or removed public API in one of your resolved
dependencies. Two ways to fix it:
- Library-side (preferred for maintainers): add a
typedef OldName = NewClass;so old consumer code keeps compiling — exactly what was done here. - Consumer-side: update the dependent package (
firebase_messaging) to a version that uses the new class name, or pin compatible versions of both packages inpubspec.yaml.
having the same issue
having the same issue
Could you use the version below for now, until the new version is published?
firebase_analytics: 12.4.3
firebase_core: ^4.12.0
cloud_firestore: 6.6.0
firebase_messaging: 16.4.1
firebase_crashlytics: 5.2.4
firebase_auth: 6.5.4
cloud_functions: 6.3.3
firebase_storage: 13.4.3
firebase_remote_config: 6.5.3
firebase_app_check: 0.4.5