expo icon indicating copy to clipboard operation
expo copied to clipboard

[docs] SDK 50 - Android 14 Foreground service permission requirements

Open robutler opened this issue 2 years ago • 8 comments

Summary

With Expo SDK 50 being upgraded to Android SDK 34 (Android 14) there seems to be new foreground permission requirements for submitting an application to Android Play Store.

When trying to submit an application to the Play Store, built with SDK 50 through EAS, I'm getting stopped by the message:

[logs] Updating track 'internal'... [logs] Uploading all changes to Google Play... [logs] Google Api Error: Invalid request - You must let us know whether your app uses any Foreground Service permissions. - Retrying...

My only guess is that this is somehow related to me using expo-location in my project, which adds a foreground service to the Android manifest.

From what I can read in Google documentation here there should be a new section in the Play console where I can fill out additional details for Foregrounds services if I'm targeting Android 14 (which SDK 50 does). However to me it seems like an chicken and the egg situation where I can't even submit my application to let Play console know that I'm targeting that Android version, because the submission process is blocking me, so that new section in the Play console isn't visible.

What is the recommended approach here for an Expo application? The documentation doesn't mention this case from what I can tell.

Link to the related docs page

https://docs.expo.dev/versions/latest/sdk/location/

Anything else?

No response

robutler avatar Feb 01 '24 12:02 robutler

An update: Doing a manual upload on Play console of the AAB artefact allows me to fill in the new foreground permission details in relation to the new release. I haven't tried submitting to the Play store from EAS again after that, but I suspect that would remove the block from the Google API as well. It did make the new "Foreground service permissions" option show up on the Play console under "App content".

robutler avatar Feb 01 '24 15:02 robutler

An update: Doing a manual upload on Play console of the AAB artefact allows me to fill in the new foreground permission details in relation to the new release. I haven't tried submitting to the Play store from EAS again after that, but I suspect that would remove the block from the Google API as well. It did make the new "Foreground service permissions" option show up on the Play console under "App content".

what details required to fill in ?

a-eid avatar Feb 04 '24 22:02 a-eid

what details required to fill in ?

They want you to declare what foreground permissions you're using, in my case with expo-location it was android.permission.FOREGROUND_SERVICE_LOCATION. They also want to know for what purpose you are using the permission. And thirdly attach a link to a video where you demonstrate how you use the permission (I just created an unlisted video on YouTube that I linked).

It's a bit of a hassle, but the review part went quite quickly, within the hour. I don't think they even watched they video according to analytics on YouTube.

robutler avatar Feb 06 '24 09:02 robutler

Same thing happened for me. I got the error on EAS submit, so then I uploaded the AAB manually to the play store. It stopped me and said I had to declare foreground services and provided a link to App Content. It gave a few choices for which permissions my app used (the app asks the user for location on one screen which I use expo-location for), and then they ask for a link to a video showing the functionality in the app. I uploaded an unlisted youtube and put in that link, and that was it.

duggster avatar Feb 14 '24 19:02 duggster

We get this as well. Tried uploading the aab manually and got the same app content link to fill in. But when using eas submit for the next version, we get the same error again... Is it going to be like this for every submit, anyone know?

emilnilimaa avatar Feb 16 '24 09:02 emilnilimaa

Is there any recommendation on what permissions need to be added for Android 14 using getCurrentPositionAsync or expo-location in general? My app had been approved by Google, but was rejected for the first time yesterday in my latest release that included Expo 50. I have filled out the additional details requested by Google to no avail.

@Kudo Apologies for roping you into this discussion, but it seems like this issue may carry a bit more weight than a simple documentation change as it appears others may be plague with this issue and get rejected by Google as they migrate to Expo 50. Do you have any insight into this matter?

Update For those who are experiencing the same problem, I was able to resubmit and get Google to approve by adding the FOREGROUND_SERVICE_LOCATION permission and I updated my video links to make sure they are visible to the user.

iM-GeeKy avatar Feb 17 '24 13:02 iM-GeeKy

This kind of seems wrong and should be something we should be able to turn off. The reason being, Google wants this if we're tracking location when the app is not in use, which in my use case, isn't tracked. This is not meant to be for applications that use location when a user has it opened for typical geo located events. Hopefully this can be corrected so we can properly use EAS to submit builds. I'm going to upload a video, but I know what might happen is that they might not like that our app is tracking in the background when it isn't. This also concerns me if this is an iOS issue or not, because they really don't like location tracking in the background either. (Thanks Uber)

brteller avatar Feb 19 '24 00:02 brteller

I'm currently experiencing the same issue. After upgrading to Expo50, I manually uploaded the EAS build file to the Google Play Console. Additionally, I recorded the parts of my app that use maps and uploaded the video to YouTube. However, Google rejected it. Probably because my app doesn't use maps in the background, and the video did not include proof of that.

Currently, with the version upgraded to Expo50, it's not possible to bypass the expo-location issue. Has anyone been able to do it? Is there any good solution?

sato-daiki avatar Feb 19 '24 07:02 sato-daiki

I'm having the same issue where the app got rejected after upgrading to expo 50 because of the added foreground service permission. Like above, I got the error, so I submitted the additional data with a video showing how the location is used (not using it in the background), but got rejected. Would love to hear if anyone got a workaround for this.

vnil avatar Feb 21 '24 06:02 vnil

Just an idea but has anyone tried blocking the permission in the app config? I'm guessing Google is only scanning the manifest for this, and if the permission is not there perhaps the app would pass like previously. Of course the would assume you don't need any background location.

robutler avatar Feb 21 '24 08:02 robutler

@robutler That seems to have worked. By blocking the permission in app.config.js I was able to submit the Android build through the API again.

expo : {
 android:{
      "blockedPermissions": [
        "FOREGROUND_SERVICE_LOCATION"
      ]

Ross-Landry avatar Feb 21 '24 16:02 Ross-Landry

@robutler Blocking the permission in the app config did the trick for me, thanks! No error/warning regarding this permission when preparing the release and Google just accepted my new release 🥳, AND the location service worked as expected in the app 😌

vnil avatar Feb 22 '24 07:02 vnil

Thank you for filing this issue! This comment acknowledges we believe this may be a bug and there’s enough information to investigate it. However, we can’t promise any sort of timeline for resolution. We prioritize issues based on severity, breadth of impact, and alignment with our roadmap. If you’d like to help move it more quickly, you can continue to investigate it more deeply and/or you can open a pull request that fixes the cause.

expo-bot avatar Feb 23 '24 19:02 expo-bot

hey folks, we are investigating what the best solution is here that we can introduce as a patch in sdk 50 without breaking anybody's apps. for now, blocking the foreground service permission is a good workaround. we'll keep you update

brentvatne avatar Feb 23 '24 22:02 brentvatne

docs are updated, and the foreground service permission is disabled by default in [email protected].

brentvatne avatar Feb 27 '24 00:02 brentvatne

@brentvatne probably related:

I'm getting this

Fatal Exception: java.lang.SecurityException
Starting FGS with type location callerApp=ProcessRecord{6ce728d 8641:xxx.xxxx.xxxxx/u0a382} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission

error. Our app hasn't changed and the only thing we did was updating to SDK 50. We don't use the foreground location service explicitly, so the only thing I can think of is that Android 14 (SDK34) included some changes that makes it so the app tries to use it underneath?

I've tried blocking the permission and I'm on the latest version of expo-location. Could it be that now getting the location or just using google maps requires the FOREGROUND_SERVICE_LOCATION permission?

Before this, I didn't have any issues without that permission. App was being built and submitted, and worked as expected.

alterx avatar Feb 27 '24 21:02 alterx

@alterx - are you getting this error when attempting to get the current location with google maps? or by calling the expo-location api?

it could be that google maps requires android.permission.FOREGROUND_SERVICE_LOCATION in this case. try enabling that with the expo-location config plugin: https://docs.expo.dev/versions/latest/sdk/location/#configurable-properties - "isAndroidForegroundServiceEnabled": true

brentvatne avatar Feb 27 '24 21:02 brentvatne

@brentvatne I'm getting at a point in the app where we request the permissions: it calls getForegroundPermissionsAsync and requests it if we don't have it. Then calls getBackgroundPermissionsAsync and requests it if we don't have it and then sets up a background location task.

We've never needed the FOREGROUND_SERVICE_LOCATION permission for doing this before

alterx avatar Feb 27 '24 21:02 alterx

@alterx - that permissions was added in android 14. so you are saying that when you call Location.requestForegroundPermissionsAsync() then you get this error on android 14 device, right?

brentvatne avatar Feb 27 '24 21:02 brentvatne

@brentvatne yeah, I do get all the permission modals, but after a couple of seconds the app crashes. And upon further investigation, that's the error I'm seeing

alterx avatar Feb 27 '24 21:02 alterx

I was able to remove that part of the code and the app runs just fine, the map also runs fine so it's definitely not it. I created a new build that calls getForegroundPermissionsAsync and then getCurrentPositionAsync and I'm able to replicate it so one of those two is probably the culprit @brentvatne

Update:

It crashes right after calling getCurrentPositionAsync

alterx avatar Feb 27 '24 21:02 alterx

@alterx - could you possibly create an issue with the full reproducible example an other info? it would be really helpful so we can get someone to quickly investigate this

brentvatne avatar Feb 27 '24 23:02 brentvatne

Sorry, I didn't get this notification earlier @brentvatne I created a new issue here https://github.com/expo/expo/issues/27336

alterx avatar Feb 28 '24 01:02 alterx

We're getting rejected for foreground service media projection as well... Can we block this permission too?

emilnilimaa avatar Feb 29 '24 20:02 emilnilimaa

@emilnilimaa - can you provide more information on exactly what you are seeing? we don't add any permissions related to "foreground service media projection" in expo-location. you should narrow down which library this is coming from.

brentvatne avatar Feb 29 '24 20:02 brentvatne

@brentvatne Yeah its probably not expo-location, but we get the same type of rejection. I am not sure which lib it is coming from unfortunately, and we have plenty. But it started appearing at the same time as we received the location rejections... God damn hate androids :P

emilnilimaa avatar Feb 29 '24 20:02 emilnilimaa

@emilnilimaa - you can search your node_modules for the permission string to see where it's coming from

brentvatne avatar Feb 29 '24 20:02 brentvatne

Which string should we search for?

emilnilimaa avatar Feb 29 '24 20:02 emilnilimaa

@emilnilimaa - whichever string google warned you about :)

brentvatne avatar Feb 29 '24 20:02 brentvatne

Well it only says this:

Permissions for Foreground Services: Service interruption or deferment of functionality does not have material user impact Details We found that one or more of the declared use cases is not compliant with how [foreground service permission](https://support.google.com/googleplay/android-developer/answer/13392821?hl=en&sjid=5928478178588015754-NA) is allowed to be used. Specifically, the declared use case(s) can be interrupted or deferred by the system without creating a negative user experience. Your app is using foreground service to Media Projection - Other when it is not required to do so.

None of our code requests any such permission, so it has to be from some lib. But not sure what to search for. Searching for MEDIA_PROJECTION finds nothing.

emilnilimaa avatar Feb 29 '24 21:02 emilnilimaa