Closed iAbdulaziz93 closed 2 months ago
This seems to be an issue with your AndroidManifest.xml
. Please try adding the required permission to it: https://stackoverflow.com/a/61277020/7686474
This seems to be an issue with your
AndroidManifest.xml
. Please try adding the required permission to it: https://stackoverflow.com/a/61277020/7686474
@JulianAssmann I already did this as shown below.
<service
android:name="de.julianassmann.flutter_background.IsolateHolderService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="mediaProjection" />
As per https://github.com/livekit/client-sdk-flutter/issues/542#issuecomment-2203292204, the problem seems to be that the foreground service needs to be started only after receiving for the screenshare permission.
Have you tried the solution proposed in the comment?
if (lkPlatformIs(PlatformType.android)) {
// Android specific
bool hasCapturePermission = await Helper.requestCapturePermission();
if (!hasCapturePermission) {
return;
}
requestBackgroundPermission([bool isRetry = false]) async {
// Required for android screenshare.
try {
bool hasPermissions = await FlutterBackground.hasPermissions;
if (!isRetry) {
const androidConfig = FlutterBackgroundAndroidConfig(
notificationTitle: 'Screen Sharing',
notificationText: 'LiveKit Example is sharing the screen.',
notificationImportance: AndroidNotificationImportance.Default,
notificationIcon: AndroidResource(
name: 'livekit_ic_launcher', defType: 'mipmap'),
);
hasPermissions = await FlutterBackground.initialize(
androidConfig: androidConfig);
}
if (hasPermissions &&
!FlutterBackground.isBackgroundExecutionEnabled) {
await FlutterBackground.enableBackgroundExecution();
}
} catch (e) {
if (!isRetry) {
return await Future<void>.delayed(const Duration(seconds: 1),
() => requestBackgroundPermission(true));
}
print('could not publish video: $e');
}
}
await requestBackgroundPermission();
}
Hi, @JulianAssmann.
Sorry for the late reply.
I already checked for permission before proceeding with the screen sharing.
Do I need to do as the code above you shared or maybe open an issue with the LiveKit team?
@JulianAssmann Solved the issue, solution: https://github.com/livekit/client-sdk-flutter/issues/582.
Describe the bug I'm trying to share the screen on a real device, the below error message is showing without crashing the app, but the share function is not working.
To Reproduce I'm using the share feature that livekit_client package is offering by using
flutter_background
package. I followed both packages' steps/docs to enable this feature.Expected behavior The share screen feature is working as expected without issues.
Smartphone:
Logs
``` [+11035 ms] E/RtgSchedIpcFile(26586): RtgSchedIpcFile failed to open /proc/26586/rtg [ ] I/RmeSchedManager(26586): init Rme, version is: v1.0 [ ] E/RtgSchedIpcFile(26586): setCommandByIoctl not opened [ ] D/RtgSched(26586): resetRtgSchedHandle failed enable:0 [ +7 ms] I/VRI[MainActivity](26586): send MSG_WINDOW_FOCUS_CHANGED msg [ +1 ms] I/PointerIcon(26586): Pointer cache recompute key = com.example [ ] D/DecorView(26586): showOrHideHighlightView: hasFocus=false; winMode=1; isMrgNull=true [ +31 ms] I/SurfaceControl(26586): SurfaceControl 0xb400007d6a93c220 [ ] I/SurfaceControl(26586): nativeRelease 0xb400007de00893c0 count: 2 [ ] I/SurfaceControl(26586): ~SurfaceControl 0xb400007de00893c0 [ ] I/SurfaceControl(26586): nativeRelease 0xb400007d7b881540 count: 2 [ ] I/SurfaceControl(26586): ~SurfaceControl 0xb400007d7b881540 [ ] I/SurfaceControl(26586): nativeRelease 0xb400007d7bae1220 count: 2 [ ] I/SurfaceControl(26586): ~SurfaceControl 0xb400007d7bae1220 [ +965 ms] D/ActivityThread(26586): Won't deliver top position change in state=4 [ +7 ms] I/SurfaceControl(26586): SurfaceControl 0xb400007d55839ae0 [ ] I/SurfaceControl(26586): SurfaceControl 0xb400007de008c660 [ ] I/SurfaceControl(26586): SurfaceControl 0xb400007d6a93ff60 [ +3 ms] I/DecorView[](26586): set decor visibility 0 [ +1 ms] I/SurfaceControl(26586): nativeRelease 0xb400007d6a93c220 count: 2 [ ] I/SurfaceControl(26586): ~SurfaceControl 0xb400007d6a93c220 [ +7 ms] I/org.webrtc.Logging(26586): EglBase14Impl: Using OpenGL ES version 2 [ +2 ms] I/BufferQueueConsumer(26586): [](id:67da00000004,api:0,p:-1,c:26586) connect: controlledByApp=true [ +3 ms] E/MethodChannel#FlutterWebRTC.Method(26586): Failed to handle method call [ ] E/MethodChannel#FlutterWebRTC.Method(26586): java.lang.SecurityException: Media projections require a foreground service of type ServiceInfo.FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.os.Parcel.createExceptionOrNull(Parcel.java:3022) [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.os.Parcel.createException(Parcel.java:3006) [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.os.Parcel.readException(Parcel.java:2989) [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.os.Parcel.readException(Parcel.java:2931) [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.media.projection.IMediaProjection$Stub$Proxy.start(IMediaProjection.java:268) [ ] E/MethodChannel#FlutterWebRTC.Method(26586): at android.media.projection.MediaProjection.