Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Android 14 (API 34+): Foreground service types are required #85

Open
kNoAPP opened this issue May 31, 2024 · 9 comments
Open

[BUG] Android 14 (API 34+): Foreground service types are required #85

kNoAPP opened this issue May 31, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@kNoAPP
Copy link

kNoAPP commented May 31, 2024

https://developer.android.com/about/versions/14/changes/fgs-types-required
https://developer.android.com/about/versions/14/changes/fgs-types-required#media-projection
https://developer.android.com/reference/android/content/pm/ServiceInfo#FOREGROUND_SERVICE_TYPE_MEDIA_PROJECTION

E/AndroidRuntime(16537): java.lang.RuntimeException: Unable to start service de.julianassmann.flutter_background.IsolateHolderService@ceb8b4b with Intent { act=START cmp=com.remotelegal.astra/de.julianassmann.flutter_background.IsolateHolderService }: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{5ba1ad5 16537:com.remotelegal.astra/u0a549} 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] 
E/AndroidRuntime(16537): 	at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:5053)
E/AndroidRuntime(16537): 	at android.app.ActivityThread.-$$Nest$mhandleServiceArgs(Unknown Source:0)
E/AndroidRuntime(16537): 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2390)
E/AndroidRuntime(16537): 	at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(16537): 	at android.os.Looper.loopOnce(Looper.java:232)
E/AndroidRuntime(16537): 	at android.os.Looper.loop(Looper.java:317)
E/AndroidRuntime(16537): 	at android.app.ActivityThread.main(ActivityThread.java:8501)
E/AndroidRuntime(16537): 	at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(16537): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/AndroidRuntime(16537): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:878)
E/AndroidRuntime(16537): Caused by: java.lang.SecurityException: Starting FGS with type mediaProjection callerApp=ProcessRecord{5ba1ad5 16537:com.remotelegal.astra/u0a549} 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] 
@kNoAPP kNoAPP added the bug Something isn't working label May 31, 2024
@ma-vai
Copy link

ma-vai commented Jun 3, 2024

We are also experiencing the same issue. There is a pending merge request for this by someone else, however it is hardcoding FGS type of "specialUse" which requires many hoops to explain when publishing to the Play Store.

It would be ideal if we can set the FGS type string in the manifest for this package, and have the package detect and send the appropriate FGS const to the android start service call.

@kNoAPP
Copy link
Author

kNoAPP commented Jun 28, 2024

@steveseguin Question, were you trying to fix this issue with your fork? Did you succeed? https://github.com/steveseguin/flutter_background

@steveseguin
Copy link

@steveseguin Question, were you trying to fix this issue with your fork? Did you succeed? https://github.com/steveseguin/flutter_background

I hacked at it until it worked. Part of the issue in my case was that I needed to explicitly request permission for display capture, and that also had to be approved by the Google reviewers.

I then had conflicts between Flutter plugins, as different ones needed different versions of other dependencies, and so that took further hacking to cut out the bits of the flutter_background plugin that were causing me grief.

Do a lot of testing if moving to Android 14, across a lot of devices, including Samsung.

https://github.com/steveseguin/vdon_flutter - final product.

The funny thing is, I have a new version written in react-native that I'm moving instead to, as I'm giving up on Flutter. This was meant to be quick hold over update, and it ended up being a big headache.

@kNoAPP
Copy link
Author

kNoAPP commented Jun 28, 2024

@steveseguin Question, were you trying to fix this issue with your fork? Did you succeed? https://github.com/steveseguin/flutter_background

I hacked at it until it worked. Part of the issue in my case was that I needed to explicitly request permission for display capture, and that also had to be approved by the Google reviewers.

I then had conflicts between Flutter plugins, as different ones needed different versions of other dependencies, and so that took further hacking to cut out the bits of the flutter_background plugin that were causing me grief.

Do a lot of testing if moving to Android 14, across a lot of devices, including Samsung.

https://github.com/steveseguin/vdon_flutter - final product.

The funny thing is, I have a new version written in react-native that I'm moving instead to, as I'm giving up on Flutter. This was meant to be quick hold over update, and it ended up being a big headache.

Thanks, this is good information. I'm running from LiveKit's videoconferencing SDK and my app breaks the moment I throw Android SDK 34 at it. Haven't been able to fix it yet before the upcoming August deadline.

@ma-vai
Copy link

ma-vai commented Jun 28, 2024

We also experienced a lot of Flutter plugin breakage when updating to Android 14/SDK 34. This background things was the most pressing issue. There is a package that supposedly handles it (https://pub.dev/packages/flutter_background_service) but it's not exactly the same as flutter_background, which I prefer as it's been great for us so far. I was hoping the way flutter_background_service implemented the FGS stuff could be done for flutter_background.

@aloRanking
Copy link

im facing this issue too.

@JulianAssmann
Copy link
Owner

JulianAssmann commented Aug 15, 2024

This should be resolved now by #89, which is part of the new 1.3.0 release. Please update to the new version and let me know, if that fixes it for you. Feel free to reopen the issue, if you still face the issue.

@subashramesh
Copy link

im still facing this issue

@JulianAssmann
Copy link
Owner

JulianAssmann commented Aug 28, 2024

@subashramesh Can you please post your error message here?
The error message from the OG poster indicates a missing permission for media projection in the AndroidManifest.xml file, which you have to add to the manifest yourself.

@JulianAssmann JulianAssmann reopened this Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants