flutter_foreground_task
flutter_foreground_task copied to clipboard
Android 14 Permission related crash
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]
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 ?
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();
Hey @bhavinb98, i am getting the same issue. Are you able to solve the issue ?
@ishabodiwala no, not yet
this may help
Have tried it already. It's not working.
@ishabodiwala Possible solution for your issue