flutter_foreground_service_plugin
flutter_foreground_service_plugin copied to clipboard
Crash when using flutter_record_screen
Hi, It crash when using flutter_screen_recording plugin:
"
I/flutter ( 2065): Foreground on Started
E/MediaRecorder( 2065): setAudioSource called in an invalid state(4)
I/System.out( 2065): Error onMethodCall startRecordScreen
I/System.out( 2065): null
I/flutter ( 2065): Foreground on Started
I/System.out( 2065): 1280 720
I/System.out( 2065): file --- /storage/emulated/0/DCIM/Title.mp4
D/AndroidRuntime( 2065): Shutting down VM
E/AndroidRuntime( 2065): FATAL EXCEPTION: main
E/AndroidRuntime( 2065): Process: com.example.flutterthe_a_app, PID: 2065
E/AndroidRuntime( 2065): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=333, result=-1, data=Intent { (has extras) }} to activity {com.example.flutterthe_a_app/com.example.flutterthe_a_app.MainActivity}: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
E/AndroidRuntime( 2065): at android.app.ActivityThread.deliverResults(ActivityThread.java:5015)
E/AndroidRuntime( 2065): at android.app.ActivityThread.handleSendResult(ActivityThread.java:5056)
E/AndroidRuntime( 2065): at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
E/AndroidRuntime( 2065): at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime( 2065): at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime( 2065): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
E/AndroidRuntime( 2065): at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime( 2065): at android.os.Looper.loop(Looper.java:223)
E/AndroidRuntime( 2065): at android.app.ActivityThread.main(ActivityThread.java:7656)
E/AndroidRuntime( 2065): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2065): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/AndroidRuntime( 2065): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/AndroidRuntime( 2065): Caused by: java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION
E/AndroidRuntime( 2065): at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
E/AndroidRuntime( 2065): at android.os.Parcel.createException(Parcel.java:2357)
E/AndroidRuntime( 2065): at android.os.Parcel.readException(Parcel.java:2340)
E/AndroidRuntime( 2065): at android.os.Parcel.readException(Parcel.java:2282)
E/AndroidRuntime( 2065): at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231)
E/AndroidRuntime( 2065): at android.media.projection.MediaProjection.
I did all the things you required, I'm using flutter_screen_recording version 1.1.1 AND have to use your 0.4.0 version due to flutter_screen_recording dependcies.
Thanks in advance :)!