flutter_foreground_task icon indicating copy to clipboard operation
flutter_foreground_task copied to clipboard

MissingForegroundServiceTypeException.java:53

Open BurhanArif2611 opened this issue 2 years ago • 5 comments

MissingForegroundServiceTypeException.java:53

java.lang.RuntimeException · Unable to create service com.pravera.flutter_foreground_task.service.ForegroundService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{ac083f5 16801:com.thrivecommunity.thrive_client/u0a143} targetSDK=34

BurhanArif2611 avatar Jan 31 '24 13:01 BurhanArif2611

i do have same issue, have you been able to resolved it?

zionnite avatar Jan 31 '24 15:01 zionnite

Nobody is saying anything about this

zionnite avatar Feb 01 '24 06:02 zionnite

This problem appears when in build.gradle set "compileSdkVersion 34". If set "compileSdkVersion 33" this problem is not appear. I think this is due to the changes https://developer.android.com/about/versions/14/changes/fgs-types-required#permission-for-fgs-type

topor00 avatar Feb 01 '24 07:02 topor00

correct... this was fix for me, i was having this issue because I targeted SDK Version 34, and by the time i downgraded it to 33 my problem was resolved

zionnite avatar Feb 01 '24 20:02 zionnite

Confirm. If I targeting sdk version to 34 the app starts to crash with error

type: crash
osVersion: google/bluejay/bluejay:14/UQ1A.240205.002/2024020500:user/release-keys
processUptime: 3030 + 205 ms
installer: com.android.packageinstaller

java.lang.RuntimeException: Unable to create service com.pravera.flutter_foreground_task.service.ForegroundService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{7432e38 29602:co.mybest.app/u11a180} targetSDK=34
 at android.app.ActivityThread.handleCreateService(ActivityThread.java:4722)
 at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2296)
 at android.os.Handler.dispatchMessage(Handler.java:106)
 at android.os.Looper.loopOnce(Looper.java:205)
 at android.os.Looper.loop(Looper.java:294)
 at android.app.ActivityThread.main(ActivityThread.java:8279)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
 at com.android.internal.os.ExecInit.main(ExecInit.java:49)
 at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
 at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:359)
Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type  callerApp=ProcessRecord{7432e38 29602:co.mybest.app/u11a180} targetSDK=34
 at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
 at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
 at android.os.Parcel.readParcelableInternal(Parcel.java:4890)
 at android.os.Parcel.readParcelable(Parcel.java:4872)
 at android.os.Parcel.createExceptionOrNull(Parcel.java:3061)
 at android.os.Parcel.createException(Parcel.java:3050)
 at android.os.Parcel.readException(Parcel.java:3026)
 at android.os.Parcel.readException(Parcel.java:2968)
 at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6805)
 at android.app.Service.startForeground(Service.java:777)
 at com.pravera.flutter_foreground_task.service.ForegroundService.w(Unknown Source:306)
 at com.pravera.flutter_foreground_task.service.ForegroundService.onCreate(Unknown Source:34)
 at android.app.ActivityThread.handleCreateService(ActivityThread.java:4709)
 ... 11 more

awaik avatar Feb 13 '24 12:02 awaik

@Dev-hwang which version has this fixed?

pankaj-nikam avatar Jul 19 '24 11:07 pankaj-nikam

@pankaj-nikam

This is not any problem or error.

Starting with Android 14 or SdkVersion 34 , you must set foregroundServiceType to start foreground service.

Please see readme for more details.

Dev-hwang avatar Jul 19 '24 12:07 Dev-hwang