Laerdal.Dfu
Laerdal.Dfu copied to clipboard
DfuInstallation.Start() throws Bad notification for startForeground thrown on .Net MAUI (Android)
Describe the bug I'm implementing the functionality to upgrade a firmware using DFU but it throws an exception when executing DfuInstallation.Start().
I've declared the Foreground Service permission on AndroidManifest.xml and a Foreground service link but it's still throwing the error.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
To Reproduce Steps to reproduce the behavior:
- Create a MAUI project (NET 8)
- Install the Laerdal.Dfu 1.27.8 NuGet package
- Include the Foreground Service permission on AndroidManifest.xml.
- Implement a Foreground service.
- Create a method to download or retrieve your firmware update file.
- Scan for the desired device to DFU.
- Create the DfuInstallation object and call Start().
Expected behavior Start and complete the DFU process with the BLE device.
Desktop:
- OS: Mac 14.1.1 (23B81)
- IDE: VS Mac 17.6.7 (build 417)
- NuGet package Laerdal.Dfu version 1.27.8
- NET Maui v8.0.100
Smartphone:
- Device: Samsung A53
- OS: Android v13
Additional context Logs:
[DfuBaseService] DFU service destroyed
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.company, PID: 11852
[AndroidRuntime] android.app.RemoteServiceException$CannotPostForegroundServiceNotificationException: Bad notification for startForeground
[AndroidRuntime] at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2222)
[AndroidRuntime] at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] at android.os.Looper.loopOnce(Looper.java:226)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:313)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:8762)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)