Starting a foreground_task crashes the app since 1.0.9

There are issues since March 13, 2025 at 12:55:00 AM GMT+1:

 PlatformException:PlatformException(ForegroundServiceStartNotAllowedException, startForegroundService() not allowed due to mAllowStartForeground false: service org.codeberg.obsapp/com.pravera.flutter_foreground_task.service.ForegroundService, null, null)
File "background_manger.dart" , line 71 , in BackgroundManager.start 

https://glitchtip.weiler.rocks/obs-app/issues/34?project=1

I think this one could be related:

java.lang.RuntimeException: Unable to start service com.pravera.flutter_foreground_task.service.ForegroundService@8894ad7 with Intent { cmp=org.codeberg.obsapp/com.pravera.flutter_foreground_task.service.ForegroundService }: java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{2b1a02 3580:org.codeberg.obsapp/u0a300} targetSDK=35 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
    at android.app.ActivityThread. handleServiceArgs (ActivityThread.java :5100 )
    at android.app.ActivityThread. -$$Nest$mhandleServiceArgs
    at android.app.ActivityThread$H. handleMessage (ActivityThread.java :2432 )
    at android.os.Handler. dispatchMessage (Handler.java :107 )
    at android.os.Looper. loopOnce (Looper.java :232 )
    at android.os.Looper. loop (Looper.java :317 )
    at android.app.ActivityThread. main (ActivityThread.java :8592 )
    at java.lang.reflect.Method. invoke (Method.java )
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller. run (RuntimeInit.java :580 )
    at com.android.internal.os.ZygoteInit. main (ZygoteInit.java :878 )

java.lang.SecurityException: Starting FGS with type location callerApp=ProcessRecord{2b1a02 3580:org.codeberg.obsapp/u0a300} targetSDK=35 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
    at android.os.Parcel. createExceptionOrNull (Parcel.java :3183 )
    at android.os.Parcel. createException (Parcel.java :3167 )
    at android.os.Parcel. readException (Parcel.java :3150 )
    at android.os.Parcel. readException (Parcel.java :3092 )
    at android.app.IActivityManager$Stub$Proxy. setServiceForeground (IActivityManager.java :6960 )
    at android.app.Service. startForeground (Service.java :863 )
    at l.g0. g (SourceFile :1 )
    at com.pravera.flutter_foreground_task.service.ForegroundService. f (SourceFile :109 )
    at com.pravera.flutter_foreground_task.service.ForegroundService. onStartCommand (SourceFile :742 )
    at android.app.ActivityThread. handleServiceArgs (ActivityThread.java :5082 )
    at android.app.ActivityThread. -$$Nest$mhandleServiceArgs
    at android.app.ActivityThread$H. handleMessage (ActivityThread.java :2432 )
    at android.os.Handler. dispatchMessage (Handler.java :107 )
    at android.os.Looper. loopOnce (Looper.java :232 )
    at android.os.Looper. loop (Looper.java :317 )
    at android.app.ActivityThread. main (ActivityThread.java :8592 )
    at java.lang.reflect.Method. invoke (Method.java )
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller. run (RuntimeInit.java :580 )
    at com.android.internal.os.ZygoteInit. main (ZygoteInit.java :878 )

android.os.RemoteException: Remote stack trace: at com.android.server.am.ActiveServices.validateForegroundServiceType(ActiveServices.java:2842) at com.android.server.am.ActiveServices.setServiceForegroundInnerLocked(ActiveServices.java:2530) at com.android.server.am.ActiveServices.setServiceForegroundLocked(ActiveServices.java:1806) at com.android.server.am.ActivityManagerService.setServiceForeground(ActivityManagerService.java:13795) at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:3483) 

https://glitchtip.weiler.rocks/obs-app/issues/10?project=1

I assume this is related to this:

https://developer.android.com/develop/background-work/services/fgs/restrictions-bg-start Apps that target Android 12 (API level 31) or higher can't start foreground services while the app is running in the background, except for a few special cases. If an app tries to start a foreground service while the app runs in the background, and the foreground service doesn't satisfy one of the exceptional cases, the system throws a ForegroundServiceStartNotAllowedException.

In addition, if an app wants to launch a foreground service that needs while-in-use permissions (for example, body sensor, camera, microphone, or location permissions), it cannot create the service while the app is in the background, even if the app falls into one of the exemptions from background start restrictions. The reason for this is explained in the section Restrictions on starting foreground services that need while-in-use permissions.