Skip to content

DfuInstallation.Start() throws Bad notification for startForeground thrown on .Net MAUI (Android) #28

@juniorsaraviao

Description

@juniorsaraviao

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:

  1. Create a MAUI project (NET 8)
  2. Install the Laerdal.Dfu 1.27.8 NuGet package
  3. Include the Foreground Service permission on AndroidManifest.xml.
  4. Implement a Foreground service.
  5. Create a method to download or retrieve your firmware update file.
  6. Scan for the desired device to DFU.
  7. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions