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

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

Closed
robutler opened this issue Feb 1, 2024 · 34 comments
Closed

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

robutler opened this issue Feb 1, 2024 · 34 comments

Comments

@robutler
Copy link

robutler commented Feb 1, 2024

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 robutler added the docs label Feb 1, 2024
@robutler
Copy link
Author

robutler commented Feb 1, 2024

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".

@amandeepmittal amandeepmittal self-assigned this Feb 4, 2024
@a-eid
Copy link

a-eid commented Feb 4, 2024

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 ?

@robutler
Copy link
Author

robutler commented Feb 6, 2024

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.

@duggster
Copy link

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.

@emilnilimaa
Copy link

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?

@iM-GeeKy
Copy link

iM-GeeKy commented Feb 17, 2024

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.

@brteller
Copy link

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)

@sato-daiki
Copy link

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?

@vnil
Copy link

vnil commented Feb 21, 2024

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.

@robutler
Copy link
Author

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.

@Ross-Landry
Copy link

@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"
      ]

@vnil
Copy link

vnil commented Feb 22, 2024

@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 😌

@expo-bot
Copy link
Collaborator

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.

@brentvatne
Copy link
Member

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 added a commit that referenced this issue Feb 27, 2024
# Why

See: #26846

tl;dr: Google Play now requires declaring usage of foreground service
permissions, and you must include a video to demonstrate the usage.

# How

- Removed the permission from **AndroidManifest.xml** so it is not added
by default. I chose this approach over adding the permission to the
block list in the config plugin, because this may impact apps that use
the permission elsewhere! This would be very confusing if it were to
impact someone. The tradeoff is that if someone is using expo-location
in a bare app (without CNG) and did not add the permissions as stated in
the README, but rather depended on the foreground service permission
being implicitly added via the library **AndroidManifest.xml**, then
updating to a new expo-location version would lead to this permission
being missing.
- Updated Android permissions data using @byCedric's scripts, which I
published as an npm package and added as a script here to make it a bit
easier in the future (`yarn permissions-sync-android` in docs).
- [x] Backport docs changes to SDK 50 if we decide to cherrypick this
change

# Test Plan

@alanjhughes is going to verify that leaving out these permissions will
have no unintended side effects.

# Checklist

- [x] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [x] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [x] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
brentvatne added a commit that referenced this issue Feb 27, 2024
See: #26846

tl;dr: Google Play now requires declaring usage of foreground service
permissions, and you must include a video to demonstrate the usage.

- Removed the permission from **AndroidManifest.xml** so it is not added
by default. I chose this approach over adding the permission to the
block list in the config plugin, because this may impact apps that use
the permission elsewhere! This would be very confusing if it were to
impact someone. The tradeoff is that if someone is using expo-location
in a bare app (without CNG) and did not add the permissions as stated in
the README, but rather depended on the foreground service permission
being implicitly added via the library **AndroidManifest.xml**, then
updating to a new expo-location version would lead to this permission
being missing.
- Updated Android permissions data using @byCedric's scripts, which I
published as an npm package and added as a script here to make it a bit
easier in the future (`yarn permissions-sync-android` in docs).
- [x] Backport docs changes to SDK 50 if we decide to cherrypick this
change

@alanjhughes is going to verify that leaving out these permissions will
have no unintended side effects.

- [x] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [x] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [x] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
@brentvatne
Copy link
Member

brentvatne commented Feb 27, 2024

docs are updated, and the foreground service permission is disabled by default in expo-location@16.5.4.

@alterx
Copy link

alterx commented Feb 27, 2024

@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.

@brentvatne
Copy link
Member

@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

@alterx
Copy link

alterx commented Feb 27, 2024

@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

@brentvatne
Copy link
Member

@alterx - that permissions was added in android 14. so you are saying that when you call [Location.requestForegroundPermissionsAsync()](https://docs.expo.dev/versions/latest/sdk/location/#locationrequestforegroundpermissionsasync) then you get this error on android 14 device, right?

@alterx
Copy link

alterx commented Feb 27, 2024

@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
Copy link

alterx commented Feb 27, 2024

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

@brentvatne
Copy link
Member

@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

@alterx
Copy link

alterx commented Feb 28, 2024

Sorry, I didn't get this notification earlier @brentvatne
I created a new issue here #27336

@emilnilimaa
Copy link

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

@brentvatne
Copy link
Member

brentvatne commented Feb 29, 2024

@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.

@emilnilimaa
Copy link

@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

@brentvatne
Copy link
Member

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

@emilnilimaa
Copy link

Which string should we search for?

@brentvatne
Copy link
Member

@emilnilimaa - whichever string google warned you about :)

@emilnilimaa
Copy link

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
Copy link

@efstathiosntonas Doing a search for that in the whole project only gets 1 hit, and thats the in the blockedPermissions I added in app.config.js

@emilnilimaa
Copy link

emilnilimaa commented Feb 29, 2024

In the app bundle explorer in google play i can see these under permissions:
android.permission.FOREGROUND_SERVICE,
android.permission.FOREGROUND_SERVICE_MEDIA_PROJECTION,
android.permission.FOREGROUND_SERVICE_MICROPHONE,

No idea what puts it in there...

And they seem to go in there even if i add the blockedPermissions in the app.config.js

@eightyfive
Copy link

I think @brteller is right here. There is no need to enable the permission if you're not using expo-location for "background" purposes...

TYPE_LOCATION

  • Background Location Updates: User-initiated location sharing – For example, Find My Friend feature, vehicle activity tracking.
  • Background Location Updates: Navigation – For example, continuing driving navigation in maps, ride tracking for ride share.
  • Geofencing – Define parameters, which surround the areas of interest.

https://support.google.com/googleplay/android-developer/answer/13392821?sjid=10403373841528529919-EU

So nothing to do with simple foreground location permissions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests