flutter-webrtc / flutter-webrtc-demo

Demo for flutter-webrtc
MIT License
1.17k stars 417 forks source link

app crash when try present #197

Open odejinmi opened 2 years ago

odejinmi commented 2 years ago

Process: com.cloudwebrtc.flutterwebrtcdemo, PID: 22639 E/AndroidRuntime(22639): java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION E/AndroidRuntime(22639): at android.os.Parcel.createException(Parcel.java:2071) E/AndroidRuntime(22639): at android.os.Parcel.readException(Parcel.java:2039) E/AndroidRuntime(22639): at android.os.Parcel.readException(Parcel.java:1987) E/AndroidRuntime(22639): at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:231) E/AndroidRuntime(22639): at android.media.projection.MediaProjection.(MediaProjection.java:58) E/AndroidRuntime(22639): at android.media.projection.MediaProjectionManager.getMediaProjection(MediaProjectionManager.java:104) E/AndroidRuntime(22639): at org.webrtc.ScreenCapturerAndroid.startCapture(ScreenCapturerAndroid.java:110) E/AndroidRuntime(22639): at com.cloudwebrtc.webrtc.OrientationAwareScreenCapturer.startCapture(OrientationAwareScreenCapturer.java:62) E/AndroidRuntime(22639): at com.cloudwebrtc.webrtc.GetUserMediaImpl$3.onReceiveResult(GetUserMediaImpl.java:479) E/AndroidRuntime(22639): at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50) E/AndroidRuntime(22639): at android.os.Handler.handleCallback(Handler.java:883) E/AndroidRuntime(22639): at android.os.Handler.dispatchMessage(Handler.java:100) E/AndroidRuntime(22639): at android.os.Looper.loop(Looper.java:214) E/AndroidRuntime(22639): at android.app.ActivityThread.main(ActivityThread.java:7386) E/AndroidRuntime(22639): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(22639): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) E/AndroidRuntime(22639): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) E/AndroidRuntime(22639): Caused by: android.os.RemoteException: Remote stack trace: E/AndroidRuntime(22639): at com.android.server.media.projection.MediaProjectionManagerService$MediaProjection.start(MediaProjectionManagerService.java:476) E/AndroidRuntime(22639): at android.media.projection.IMediaProjection$Stub.onTransact(IMediaProjection.java:135) E/AndroidRuntime(22639): at android.os.Binder.execTransactInternal(Binder.java:1021) E/AndroidRuntime(22639): at android.os.Binder.execTransact(Binder.java:994) E/AndroidRuntime(22639):

Rexobias commented 2 years ago

Here's the solution: https://github.com/flutter-webrtc/flutter-webrtc/issues/979

The crash only happens when targetSdkVersion is higher than 28.