question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fatal exception. Bad notification for startForeground.

See original GitHub issue

This exception occurs in SDK 27 (Android 8.1) but not in lower SDK versions.

Fatal Exception: android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x42 color=0x00000000 groupKey=com.clamber vis=PRIVATE)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1768)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:164)
       at android.app.ActivityThread.main(ActivityThread.java:6494)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Turning off notifications prevents the exception from occurring.

    const options = {
      // ...
      notification: {
        // Required to prevent 
        enabled: false,
      },
    };

The issue appears to be fairly common and widely document for other libraries. I believe this is the same issue on SO.

I don’t have a reproduction available but I believe there is one in an issue on this other upload library

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
peterentcommented, May 24, 2019

Using APK 28. After searching and searching I finally found this thread. I turned notification off. Now the app doesn’t crash. Instead, it throws this error: “Android Oreo requires a notification configuration for the service to run. https://developer.android.com/reference/android/content/Context.html#startForegroundService(android.content.Intent)

2reactions
dtuitecommented, Feb 2, 2018

Ready for review.

Read more comments on GitHub >

github_iconTop Results From Across the Web

startForeground fail after upgrade to Android 8.1
After some tinkering for a while with different solutions i found out that one must create a notification channel in Android 8.1 and...
Read more >
Bad notification for startForeground crash on >= Android 8.1 ...
@philips77 I am experiencing the same issue, which crashes our app whenever we try to run a DFU. Here is the error: FATAL...
Read more >
Bad notification for startForeground: java.lang ... - 51CTO博客
RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException,安卓开发8.1以上系统启动服务和通知报错 android.app.
Read more >
DFU App Crash - Bad notification for startForeground
So I came across an issue while working on developing an app that can update firmware OTA. I was using Nordic Semi -...
Read more >
【错误记录】前台进程报错( Bad notification for ... - CSDN博客
RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel for service notification: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found