Permission `FOREGROUND_SERVICE_MEDIA_PROJECTION` should be added to AndroidManifest.xml
acgacgacgacg opened this issue · comments
Ketian Wu commented
On Android 14, the background service will cause the app to crash unless FOREGROUND_SERVICE_MEDIA_PROJECTION
is added to AndroidManifest.xml.
Here is the crash log
Fatal Exception: java.lang.RuntimeException
Unable to start service de.julianassmann.flutter_background.IsolateHolderService@8212701 with Intent { act=START cmp=com.example.app/de.julianassmann.flutter_background.IsolateHolderService }: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{28e5a1d 21645:com.example.app/u0a129} 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]
Adding the following line to AndroidManifest.xml solves the problem.
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION" />
I think this should be added to the document and example app in case anyone encounters the same issue.
Ketian Wu commented
@davidliu
After permission added, we still detected this crash through crash report.
Two devices: Google Pixel7, Google Pixel7a had this issue.
The crash log is the same as the one I reported here.
We do not have a Pixel7 device to reproduce this problem. Can you help us identify the problem?