ChangJoo-Park / flutter_foreground_service_plugin

MIT License
40 stars 71 forks source link

Crash when using flutter_record_screen #33

Open Lix-ai opened 3 years ago

Lix-ai commented 3 years ago

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.(MediaProjection.java:59) E/AndroidRuntime( 2065): at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:119) E/AndroidRuntime( 2065): at com.isvisoft.flutter_screen_recording.FlutterScreenRecordingPlugin.onActivityResult(FlutterScreenRecordingPlugin.kt:66) E/AndroidRuntime( 2065): at io.flutter.embedding.engine.FlutterEnginePluginRegistry$FlutterEngineActivityPluginBinding.onActivityResult(FlutterEnginePluginRegistry.java:691) E/AndroidRuntime( 2065): at io.flutter.embedding.engine.FlutterEnginePluginRegistry.onActivityResult(FlutterEnginePluginRegistry.java:378) E/AndroidRuntime( 2065): at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onActivityResult(FlutterActivityAndFragmentDelegate.java:625) E/AndroidRuntime( 2065): at io.flutter.embedding.android.FlutterActivity.onActivityResult(FlutterActivity.java:583) E/AndroidRuntime( 2065): at android.app.Activity.dispatchActivityResult(Activity.java:8305) E/AndroidRuntime( 2065): at android.app.ActivityThread.deliverResults(ActivityThread.java:5008) E/AndroidRuntime( 2065): ... 11 more E/AndroidRuntime( 2065): Caused by: android.os.RemoteException: Remote stack trace: E/AndroidRuntime( 2065): at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:479) E/AndroidRuntime( 2065): at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135) E/AndroidRuntime( 2065): at android.os.Binder.execTransactInternal(Binder.java:1154) E/AndroidRuntime( 2065): at android.os.Binder.execTransact(Binder.java:1123) E/AndroidRuntime( 2065): I/Process ( 2065): Sending signal. PID: 2065 SIG: 9 Lost connection to device. "

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 :)!

prashantspandey commented 3 years ago

did you find any solution?

Lix-ai commented 3 years ago

No, pending this feature for now..

ifananomali commented 3 years ago

Any updates on this?

prashantspandey commented 2 years ago

any updates?