RemoteServiceException: Bad notification for startForeground crash on >= Android 8.1
See original GitHub issueThere is an issue related to the updates in Android system, Since Android 8.1 you need to create own notification channel for foreground service
So in DfuBaseService in startForeground method you need to add something like this:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel chan = new NotificationChannel(NOTIFICATION_CHANNEL_DFU, "Update service",NotificationManager.IMPORTANCE_NONE); chan.setLightColor(Color.BLUE); chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE); NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); service.createNotificationChannel(chan); }
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Bad notification for startForeground (Android 8.1+) - B4X
Service Starter Start android.app.RemoteServiceException: Bad notification for startForeground: java.lang.RuntimeException: invalid channel ...
Read more >android.app.RemoteServiceException: Bad notification for ...
But I got the error below on Android 8.1, 9.0 and 10.0 Emulator. android.app.RemoteServiceException: Bad notification for startForeground: java.
Read more >Android – Bad notification for start Foreground, Invalid ...
The problem i am having is these logs don't provide any log from where i can see the source in my app that...
Read more >Startup Crash on Android 8.1 (#1124) · Issues - briar
RemoteServiceException : Bad notification for startForeground: java.lang ... Crash on Android 8.1 to Startup Crash on Android 8.1 4 years ago.
Read more >android 8.1 invalid channel for service notification
RemoteServiceException : Bad notification for startForeground: java.lang. ... 大于26时,这个channel需要进行系统注册,否则会crash,crash信息如下:android.app.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

It was finally fixed on Android 12: https://issuetracker.google.com/issues/192032398#comment6
@philips77 I am experiencing the same issue, which crashes our app whenever we try to run a DFU.
Here is the error:
Based on the Stack Overflow post, “startForeground fail after upgrade to Android 8.1”, and the research by @krtkv, it seems the function startForeground in DfuBaseService.java should be updated to include the NotificationChannel. I could work on changing it, but I don’t have a great way to test the changes before creating a pull request. Is that something you are able to change/test/push/version? If so, it would be much appreciated!