[READ] Step 1: Are you in the right place? ✅
[REQUIRED] Step 2: Describe your environment
- Android Studio version: N/A
- Firebase Component:
firebase-messaging
- Component version:
25.0.2
[REQUIRED] Step 3: Describe the problem
firebase-messaging calls MessagingAnalytics.logToScion() when the intent carries the "google.c.a.e=1" extra (Constants.AnalyticsKeys.ENABLED). logToScion() references AnalyticsConnector as a local variable type (despite the nearby TODO b/78465387) which causes a NoClassDefFoundError at method-invocation time on any build that excludes firebase-analytics. The SDK comment claims missing analytics is handled gracefully, but the class-load crash happens before any null-check can run.
Culprit code
Steps to reproduce:
- Fully disable Firebase Measurement Connector as per this Stack Overflow answer. Most notably:
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector' [edit: corrected from Firebase Analytics -> Firebase Measurement Connector]
- Send a test Firebase message whilst target app is open
- Observe crash:
FATAL EXCEPTION: Firebase-Messaging-Intent-Handle
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/analytics/connector/AnalyticsConnector;
at com.google.firebase.messaging.MessagingAnalytics.logToScion(MessagingAnalytics.java:313)
at com.google.firebase.messaging.MessagingAnalytics.logNotificationReceived(MessagingAnalytics.java:80)
at com.google.firebase.messaging.FirebaseMessagingService.passMessageIntentToSdk(FirebaseMessagingService.java:202)
at com.google.firebase.messaging.FirebaseMessagingService.handleMessageIntent(FirebaseMessagingService.java:190)
at com.google.firebase.messaging.FirebaseMessagingService.handleIntent(FirebaseMessagingService.java:179)
at com.google.firebase.messaging.EnhancedIntentService.lambda$processIntent$0$com-google-firebase-messaging-EnhancedIntentService(EnhancedIntentService.java:82)
at com.google.firebase.messaging.EnhancedIntentService$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1100)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at com.google.android.gms.common.util.concurrent.zza.run(com.google.android.gms:play-services-basement@@18.3.0:2)
Workaround
Stripping the extra by overriding handleIntent in a custom FirebaseMessagingService prevents shouldUploadScionMetrics() from returning true, so logToScion() is never entered and AnalyticsConnector is never loaded.
class MyFcmService : FirebaseMessagingService() {
override fun handleIntent(intent: Intent) {
intent.removeExtra("google.c.a.e")
super.handleIntent(intent)
}
}
[READ] Step 1: Are you in the right place? ✅
[REQUIRED] Step 2: Describe your environment
firebase-messaging25.0.2[REQUIRED] Step 3: Describe the problem
firebase-messaging calls
MessagingAnalytics.logToScion()when the intent carries the "google.c.a.e=1" extra (Constants.AnalyticsKeys.ENABLED).logToScion()referencesAnalyticsConnectoras a local variable type (despite the nearby TODOb/78465387) which causes aNoClassDefFoundErrorat method-invocation time on any build that excludes firebase-analytics. The SDK comment claims missing analytics is handled gracefully, but the class-load crash happens before any null-check can run.Culprit code
Steps to reproduce:
exclude group: 'com.google.firebase', module: 'firebase-measurement-connector'[edit: corrected from Firebase Analytics -> Firebase Measurement Connector]Workaround
Stripping the extra by overriding
handleIntentin a customFirebaseMessagingServicepreventsshouldUploadScionMetrics()from returning true, sologToScion()is never entered and AnalyticsConnector is never loaded.