ekasetiawans / flutter_background_service

269 stars 192 forks source link

Unable to create service id.flutter.flutter_background_service.BackgroundService: #421

Open shinewanna opened 8 months ago

shinewanna commented 8 months ago

Receiving this issue from crashlyics. How to fix this issue?

Fatal Exception: java.lang.RuntimeException
Unable to create service id.flutter.flutter_background_service.BackgroundService: android.app.ForegroundServiceStartNotAllowedException: Service.startForeground() not allowed due to mAllowStartForeground false: service com.example.app/id.flutter.flutter_background_service.BackgroundService
fronald commented 7 months ago

Add permission:

    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
shinewanna commented 7 months ago

My app already has that permission.

sagar1garg commented 5 months ago

Any solution to this? I am getting the same issue when app is closed.

fronald commented 3 months ago

Yep. I'ill close this issue.

The problem was that in my pubspec file there were references to flutter_background_service and background_processes. I removed background_processes and everything worked as expected. Therefore, the problem was this conflict. When encountering this error, check if there is any other functionally conflicting library in the pubspec, such as background_processes, flutter_foreground_tasks, etc.

lollipopkit commented 3 months ago

Same issue, but permission added and no conflict lib (i guess)

image