Furqan Khan
Furqan Khan

Reputation: 538

Unexplained BadForegroundServiceNotificationException in Crashlytics logs with varying layout references

I'm encountering a crash in production that I cannot reproduce locally. The crash is logged in Crashlytics as follows:

    Fatal Exception: android.app.RemoteServiceException$BadForegroundServiceNotificationException: Bad notification(tag=null, id=187544) posted from package com.example.android, crashing app(uid=10187, pid=18102): Couldn't inflate contentViewsandroid.widget.RemoteViews$ActionException: android.view.InflateException: Binary XML file line #77 in com.example.android:layout/preference_widget_seekbar: Binary XML file line #77 in com.example.android:layout/preference_widget_seekbar: Error inflating class androidx.preference.UnPressableLinearLayout
   at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2019)
   at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(ActivityThread.java)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2275)
   at android.os.Handler.dispatchMessage(Handler.java:106)
   at android.os.Looper.loopOnce(Looper.java:201)
   at android.os.Looper.loop(Looper.java:288)
   at android.app.ActivityThread.main(ActivityThread.java:7937)
   at java.lang.reflect.Method.invoke(Method.java)
   at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1019)

The exception references a layout file notification_content, but neither the foreground service nor the notification in my code uses this layout. Interestingly, the referenced file name (layout/notification_content) changes in different crash logs, suggesting this may not directly relate to a specific file in my app. The crash occurs on production devices only and is not reproducible in development or testing environments. I’ve tried the following without success:

  1. Verified that all my notification layouts are properly defined and
    compatible across target SDKs.
  2. Checked for any dynamically loaded or third-party components that might interact with notifications.
  3. Reviewed existing Stack Overflow answers and implemented all relevant suggestions, such as ensuring all notification IDs are unique and using valid RemoteViews layouts, but the issue persists.

Has anyone encountered a similar issue? Could this be related to:

Any insights or troubleshooting suggestions would be greatly appreciated.

Upvotes: 1

Views: 54

Answers (1)

ZeeDev
ZeeDev

Reputation: 1

I have been battling this same issue for a year. I can confirm the following from my own tests and crashlytics reports:

  1. It happens after an app update. After every new release there is a spike in these crashes for a short time on the new version, then they go away after a while.
  2. it is only happening (at least on my reports) on Samsung devices running Android 14. No issues with 15 or anything pre-14

My app relies heavily on foreground notifications that are likely present while the app is updated. Guessing that in some scenario the device is keeping a reference to the old remote views and then trying to update them after the layout IDs have changed with the new version.

Upvotes: 0

Related Questions