Dev-hwang / flutter_foreground_task

This plugin is used to implement a foreground service on the Android platform.
https://pub.dev/packages/flutter_foreground_task
MIT License
149 stars 109 forks source link

Error in API 34 android devices #246

Closed AbduraufDev closed 3 months ago

AbduraufDev commented 3 months ago

Compat change id reported: 160794467; UID 10194; state: ENABLED D/EGL_emulation( 3786): app_time_stats: avg=14.73ms min=4.90ms max=42.62ms count=53 D/AndroidRuntime( 3786): Shutting down VM E/AndroidRuntime( 3786): FATAL EXCEPTION: main E/AndroidRuntime( 3786): Process: com.example.example, PID: 3786 E/AndroidRuntime( 3786): java.lang.RuntimeException: Unable to create service com.pravera.flutter_foreground_task.service.ForegroundService: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{49c6da0 3786:com.example.example/u0a194} targetSDK=34 E/AndroidRuntime( 3786): at android.app.ActivityThread.handleCreateService(ActivityThread.java:4664) E/AndroidRuntime( 3786): at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0) E/AndroidRuntime( 3786): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2264) E/AndroidRuntime( 3786): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime( 3786): at android.os.Looper.loopOnce(Looper.java:205) E/AndroidRuntime( 3786): at android.os.Looper.loop(Looper.java:294) E/AndroidRuntime( 3786): at android.app.ActivityThread.main(ActivityThread.java:8177) E/AndroidRuntime( 3786): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 3786): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) E/AndroidRuntime( 3786): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) E/AndroidRuntime( 3786): Caused by: android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{49c6da0 3786:com.example.example/u0a194} targetSDK=34 E/AndroidRuntime( 3786): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53) E/AndroidRuntime( 3786): at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49) E/AndroidRuntime( 3786): at android.os.Parcel.readParcelableInternal(Parcel.java:4870) E/AndroidRuntime( 3786): at android.os.Parcel.readParcelable(Parcel.java:4852) E/AndroidRuntime( 3786): at android.os.Parcel.createExceptionOrNull(Parcel.java:3052) E/AndroidRuntime( 3786): at android.os.Parcel.createException(Parcel.java:3041) E/AndroidRuntime( 3786): at android.os.Parcel.readException(Parcel.java:3024) E/AndroidRuntime( 3786): at android.os.Parcel.readException(Parcel.java:2966) E/AndroidRuntime( 3786): at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:6761) E/AndroidRuntime( 3786): at android.app.Service.startForeground(Service.java:862) E/AndroidRuntime( 3786): at com.pravera.flutter_foreground_task.service.ForegroundService.startForegroundService(ForegroundService.kt:224) E/AndroidRuntime( 3786): at com.pravera.flutter_foreground_task.service.ForegroundService.onCreate(ForegroundService.kt:84) E/AndroidRuntime( 3786): at android.app.ActivityThread.handleCreateService(ActivityThread.java:4651) E/AndroidRuntime( 3786): ... 9 more I/Process ( 3786): Sending signal. PID: 3786 SIG: 9

Dev-hwang commented 3 months ago

@AbduraufUZB

To start the foreground service on Android 14+, you need to add foregroundServiceType.

Check readme

AbduraufDev commented 3 months ago

@AbduraufUZB

To start the foreground service on Android 14+, you need to add foregroundServiceType.

Check readme

Thank u

AbduraufDev commented 3 months ago

Thanks