flutter_foreground_task icon indicating copy to clipboard operation
flutter_foreground_task copied to clipboard

Android 14 Permission related crash

Open bhavinb98 opened this issue 11 months ago • 6 comments

I already have the following permissions declared in my manifest but it still throws an error and crashes. Flutter version - 3.19.3 Plugin Version - 6.1.3

<uses-permission android:name="android.permission.CAPTURE_VIDEO_OUTPUT" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MICROPHONE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CAMERA" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
<service
    android:name="com.pravera.flutter_foreground_task.service.ForegroundService"
    android:foregroundServiceType="mediaPlayback|camera|microphone|mediaProjection"
    android:stopWithTask="true"/>
java.lang.RuntimeException: Unable to create service com.pravera.flutter_foreground_task.service.ForegroundService: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{73ae391 7353:com.sprintstudio.conversations/u0a190} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION] any of the permissions allOf=false [android.permission.CAPTURE_VIDEO_OUTPUT, android:project_media]

bhavinb98 avatar Mar 15 '24 07:03 bhavinb98

I am using other permissions, but they need to be not only in the manifest, but explicitly asked to the user (with permission_handler pluggin for exemple). Maybe this is the same for you ? Have you tried to ask them to the user ?

GaelleJoubert avatar Mar 25 '24 13:03 GaelleJoubert

Yes, I am asking the relevant permissions.

I'm also asking for these permissions which are required for foreground task to work

await FlutterForegroundTask.requestIgnoreBatteryOptimization();
await FlutterForegroundTask.requestNotificationPermission();

bhavinb98 avatar Mar 26 '24 15:03 bhavinb98

Hey @bhavinb98, i am getting the same issue. Are you able to solve the issue ?

ishabodiwala avatar Apr 22 '24 14:04 ishabodiwala

@ishabodiwala no, not yet

bhavinb98 avatar May 16 '24 08:05 bhavinb98

this may help

UnluckyY1 avatar May 17 '24 15:05 UnluckyY1

Have tried it already. It's not working.

bhavinb98 avatar May 17 '24 15:05 bhavinb98

@ishabodiwala Possible solution for your issue

bhavinb98 avatar May 24 '24 14:05 bhavinb98