Google PlayStore reject app due to accessing the location in the background

Please provide the following:

  1. SDK Version: 39
  2. Platforms(Android/iOS/web/all): Android

I only need to get a location in the foreground and there is how I’m using the module “expo-location” below.
However, my app got rejected from Google PlayStore due to accessing the location in the background.

Google PlayStore suggested restricting accessing the location in the background.

How can I exclude the background location with SDK39?

in addition to that, while I was searching for a solution about this I found a post suggesting upgrade SDK to 40 and I tried but it turned out as an error. So I need a solution for this with SDK 39.

Thank you.

https://stackoverflow.com/questions/65841459/expo-sdk40-upgrade-typeerror-undefined-is-not-an-object-evaluating-inspect-cu

expo diagnostics

  Expo CLI 4.0.17 environment info:
    System:
      OS: macOS 11.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 14.5.0 - /usr/local/bin/node
      Yarn: 1.22.10 - /usr/local/bin/yarn
      npm: 6.14.11 - /usr/local/bin/npm
    Managers:
      CocoaPods: 1.9.3 - /usr/local/bin/pod
    SDKs:
      iOS SDK:
        Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
    IDEs:
      Android Studio: 4.0 AI-193.6911.18.40.6514223
      Xcode: 12.3/12C33 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^39.0.5 => 39.0.5 
      react: 16.13.1 => 16.13.1 
      react-dom: 16.13.1 => 16.13.1 
      react-native: https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz => 0.63.2 
      react-native-web: ^0.13.18 => 0.13.18 
      react-navigation: ^4.4.3 => 4.4.3 
    npmGlobalPackages:
      expo-cli: 4.0.17
    Expo Workflow: managed

package.json

{
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios",
    "web": "expo start --web",
    "eject": "expo eject"
  },
  "dependencies": {
    "@expo/react-native-action-sheet": "^3.8.0",
    "@expo/vector-icons": "^10.2.1",
    "@react-native-community/async-storage": "^1.12.1",
    "@react-native-community/checkbox": "^0.5.5",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "5.9.6",
    "@react-native-community/picker": "1.6.6",
    "@react-native-community/viewpager": "4.1.6",
    "@react-navigation/bottom-tabs": "^5.10.2",
    "@react-navigation/drawer": "^5.10.2",
    "@react-navigation/material-top-tabs": "5.2.16",
    "@react-navigation/native": "^5.8.2",
    "@react-navigation/stack": "^5.11.1",
    "axios": "^0.20.0",
    "debounce": "^1.2.0",
    "expo": "^39.0.5",
    "expo-asset": "~8.2.0",
    "expo-av": "~8.6.0",
    "expo-background-fetch": "~8.5.0",
    "expo-barcode-scanner": "~9.0.0",
    "expo-blur": "~8.2.0",
    "expo-brightness": "~8.3.0",
    "expo-camera": "~9.0.0",
    "expo-contacts": "~8.5.0",
    "expo-device": "~2.3.0",
    "expo-file-system": "~9.2.0",
    "expo-font": "~8.3.0",
    "expo-linear-gradient": "~8.3.0",
    "expo-location": "~9.0.0",
    "expo-media-library": "~9.2.1",
    "expo-network": "~2.3.0",
    "expo-notifications": "~0.7.2",
    "expo-permissions": "~9.3.0",
    "expo-screen-capture": "^1.1.1",
    "expo-sms": "~8.3.1",
    "expo-splash-screen": "~0.6.2",
    "expo-sqlite": "~8.4.0",
    "expo-status-bar": "~1.0.2",
    "expo-task-manager": "~8.5.0",
    "expo-updates": "^0.3.5",
    "expo-video-player": "^1.6.1",
    "expo-video-thumbnails": "~4.3.0",
    "expo-web-browser": "~8.5.0",
    "fiction-expo-restart": "^1.0.5",
    "formik": "^2.2.1",
    "jsbarcode": "^3.11.3",
    "lodash": "^4.17.20",
    "lottie-ios": "3.1.8",
    "lottie-react-native": "~2.6.1",
    "moment": "^2.29.1",
    "prop-types": "^15.7.2",
    "query-string": "^6.13.6",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
    "react-native-animatable": "^1.3.3",
    "react-native-appearance": "~0.3.3",
    "react-native-auto-height-image": "^3.2.3",
    "react-native-autoheight-webview": "^1.5.4",
    "react-native-elements": "^2.3.2",
    "react-native-expo-image-cache": "^4.1.0",
    "react-native-extended-stylesheet": "^0.12.0",
    "react-native-gesture-handler": "~1.7.0",
    "react-native-image-gallery": "^2.1.5",
    "react-native-image-slider": "^2.0.3",
    "react-native-image-zoom-viewer": "^3.0.1",
    "react-native-modal": "^11.5.6",
    "react-native-qrcode-svg": "^6.0.6",
    "react-native-reanimated": "~1.13.0",
    "react-native-safe-area-context": "3.1.4",
    "react-native-screens": "~2.10.1",
    "react-native-scrollable-tab-view": "^1.0.0",
    "react-native-svg": "12.1.0",
    "react-native-tab-view": "2.15.1",
    "react-native-vector-icons": "^7.1.0",
    "react-native-web": "^0.13.18",
    "react-native-webview": "10.7.0",
    "react-navigation": "^4.4.3",
    "react-navigation-drawer": "^2.6.0",
    "react-navigation-header-buttons": "5.0.2",
    "react-redux": "^7.2.2",
    "react-refresh": "^0.9.0",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "styled-components": "^5.2.1",
    "urijs": "^1.19.2"
  },
  "devDependencies": {
    "@babel/core": "^7.12.3",
    "@babel/plugin-syntax-class-properties": "^7.12.1",
    "@babel/runtime": "^7.12.1",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.1",
    "babel-plugin-module-resolver": "^4.0.0",
    "babel-preset-expo": "^8.3.0",
    "jest": "^26.6.1",
    "metro-react-native-babel-preset": "^0.60.0"
  },
  "private": true,
  "jest": {
    "preset": "react-native"
  }
}

if (AppState.currentState != "active") return;
      let { status } = await Location.requestPermissionsAsync();
      if (status !== "granted") {
        // setErrorMsg("Permission to access location was denied");
      }
      if (location == null) {
        let location = await Location.getLastKnownPositionAsync();
        setLocation(location);
      }

app.json

"permissions": [
        "CAMERA",
        "FOREGROUND_SERVICE",
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "READ_EXTERNAL_STORAGE",
        "READ_INTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE"
      ]

same problem here, Google Play Store sees an old version of my app asking for background location even when I have not specified it in the app.json for the latest. I am on SDK40. Check which version of the app you have uploaded that they are saying have background location, seems like this might be a bug in their automated checks.

My app.json:

      "permissions": [
        "NOTIFICATIONS",
        "USER_FACING_NOTIFICATIONS",
        "CAMERA",
        "CAMERA_ROLL",
        "READ_EXTERNAL_STORAGE",
        "WRITE_EXTERNAL_STORAGE",
        "VIBRATE"
      ]
    },
1 Like

Same issue here. I’ve contacted their support.
Expo staff, I’d suggest to remove this permission from the default set of permissions (when the ‘permissions’ key is missing from app.json). this causes issues.

This is from the SDK 40 blog post:

Yes, I saw the post however what I need is foreground location and restrict background location.
Is there any way to use foreground location while restricting accessing in the background with SDK39?

I removed permissions
“FOREGROUND_SERVICE”,
“ACCESS_COARSE_LOCATION”,
“ACCESS_FINE_LOCATION”,

and tried but Location.getLastKnownPositionAsync(); didn’t get the location.

ok everyone, I got it to work. I just filled the form, explaining that the permission was asked by mistake and that I’m submitting a new one. added a video link from our marketing department and was able to upload a new version

1 Like

My understanding is that if you want to call Location.getLastKnownPositionAsync() you will need all of those permissions.

My message was in response to this:

In SDK 40, the ACCESS_BACKGROUND_LOCATION permission is excluded by default. If you need it you have to add it in manually. If you want to cut out all of the default permissions, you should use an empty permissions array in your app.js.

In SDK 39, you will need to specify an empty permissions array (if you don’t want any location services at all) or ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION", "FOREGROUND_SERVICE"] if you only use location services in the foreground.

As mentioned by @svarto an old version of the app (e.g. an in house testing version) that does have the ACCESS_BACKGROUND_LOCATION permission (either by default or explicitly specified) might cause Google to reject your app.

I have uploaded a new build based on SDK40, it still didn’t get approved for the background location thing. Anyone has any ideas?

Same problem here !

My app do not use any background location and my app do not require any special permission
and i make sure this in app.json by setting “permissions”: ,

The package-lock.json contains an expo entry
“expo-location”: {
“version”: “10.0.0”,
“resolved”: “https://registry.npmjs.org/expo-location/-/expo-location-10.0.0.tgz”,
},

i removed it and took the build and published to playstore but rejected

the rejection reason is always the same :
Reason:
Since your app does not need background location, please request to remove background usage and reach compliance:

  • If you are targeting Android 10 or newer (SDK level 29 or higher):
    • Remove the ACCESS_BACKGROUND_LOCATION permission from your app APK or app bundle.
    • If you’re using ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION, examine your code paths and restrict usage to foreground purposes only. ([learn more]

I read some questions about this same issue in the forum and they solved it with just an empty permission in app.json

“permissions”: ,

But after doing all these tings my app keeps rejecting by play store

1 Like
  1. Are you using managed or bare app?

  2. What SDK version do you use?

  3. What packages do you use? (e.g. list your package.json)

  4. What is the output of aapt2 d permissions path/to/app.apk (See this installation/usage guide] of aapt2)

  5. What is the name of your app (e.g. @acme/app)

Same issue here. I am using:

  1. Managed app
  2. SDK 40, expo version 4.1.5
  3. Permissions: [“NOTIFICATIONS”, “CAMERA”, “CONTACTS”, “MEDIA_LIBRARY”]
  4. slug: glede.
  5. Package.json (expo-location is automatically added to package-lock.json when I run expo install):
"dependencies": {
    "@benawad/expo-mixpanel-analytics": "^0.1.7",
    "@expo/vector-icons": "^12.0.0",
    "@fortawesome/fontawesome-svg-core": "^1.2.30",
    "@fortawesome/free-brands-svg-icons": "^5.14.0",
    "@fortawesome/free-regular-svg-icons": "^5.14.0",
    "@fortawesome/free-solid-svg-icons": "^5.14.0",
    "@fortawesome/react-native-fontawesome": "^0.2.5",
    "@ptomasroos/react-native-multi-slider": "^2.2.2",
    "@react-native-community/art": "^1.2.0",
    "@react-native-community/async-storage": "~1.12.0",
    "@react-native-community/datetimepicker": "3.0.4",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/slider": "3.0.3",
    "@react-native-firebase/app": "^8.2.0",
    "@react-navigation/bottom-tabs": "^5.6.1",
    "@react-navigation/material-top-tabs": "^5.2.16",
    "@react-navigation/native": "^5.7.3",
    "@react-navigation/stack": "^5.7.1",
    "@types/mixpanel-browser": "^2.35.4",
    "@types/react-instantsearch-native": "^6.3.0",
    "@types/react-native-datepicker": "^1.7.0",
    "@types/react-native-keyboard-spacer": "^0.4.1",
    "@types/react-redux": "^7.1.9",
    "@types/uuid": "^8.3.0",
    "@typescript-eslint/eslint-plugin": "^3.9.1",
    "@typescript-eslint/parser": "^3.9.1",
    "algoliasearch": "^4.4.0",
    "axios": "^0.19.2",
    "babel-plugin-inline-dotenv": "^1.5.0",
    "body-scroll-lock": "^3.0.3",
    "cc-validate": "^2.0.5",
    "cookie-parser": "^1.4.5",
    "creditcard.js": "^2.1.6",
    "dotenv": "^8.2.0",
    "eslint": "^7.7.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.6",
    "expo": "^40.0.0",
    "expo-asset": "~8.2.1",
    "expo-auth-session": "~3.0.0",
    "expo-av": "~8.7.0",
    "expo-background-fetch": "~8.6.0",
    "expo-blur": "~8.2.2",
    "expo-camera": "~9.1.0",
    "expo-constants": "~9.3.3",
    "expo-contacts": "~8.6.0",
    "expo-face-detector": "~8.4.0",
    "expo-file-system": "~9.3.0",
    "expo-font": "~8.4.0",
    "expo-image-manipulator": "~8.4.0",
    "expo-image-picker": "~9.2.0",
    "expo-linear-gradient": "~8.4.0",
    "expo-linking": "~2.0.0",
    "expo-mail-composer": "~9.0.0",
    "expo-media-library": "~10.0.0",
    "expo-notifications": "~0.8.2",
    "expo-random": "~10.0.0",
    "expo-react-native-shadow": "^1.0.3",
    "expo-splash-screen": "~0.8.1",
    "expo-status-bar": "~1.0.3",
    "expo-updates": "~0.4.1",
    "expo-video-thumbnails": "~4.4.0",
    "expo-web-browser": "~8.6.0",
    "express": "^4.17.1",
    "firebase": "8.0.1",
    "lodash": "^4.17.20",
    "lottie-react-native": "~2.6.1",
    "mixpanel-browser": "^2.39.0",
    "moment": "^2.29.1",
    "node-pre-gyp": "^0.15.0",
    "nodemailer": "^6.4.10",
    "prettier": "^2.0.5",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-instantsearch-native": "^6.7.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz",
    "react-native-alert-async": "^1.0.5",
    "react-native-animated-background-color-view": "^1.3.1",
    "react-native-app-link": "^1.0.0",
    "react-native-axios": "^0.17.1",
    "react-native-confetti-cannon": "^1.5.1",
    "react-native-credit-card-input": "^0.4.1",
    "react-native-dash": "0.0.11",
    "react-native-datepicker": "^1.7.2",
    "react-native-dotenv": "^2.4.0",
    "react-native-easy-markdown": "^2.0.0",
    "react-native-elements": "^2.3.2",
    "react-native-emoji": "^1.8.0",
    "react-native-gesture-handler": "~1.8.0",
    "react-native-indicator": "^1.2.2",
    "react-native-keyboard-spacer": "^0.4.1",
    "react-native-mail": "^5.0.1",
    "react-native-map-clustering": "^3.3.9",
    "react-native-maps": "0.27.1",
    "react-native-modal": "^11.5.6",
    "react-native-modal-datetime-picker": "^9.1.0",
    "react-native-open-maps": "^0.3.5",
    "react-native-paper": "^4.0.1",
    "react-native-parallax-scroll-view": "^0.21.3",
    "react-native-progress": "^4.1.2",
    "react-native-reanimated": "~1.13.0",
    "react-native-redash": "^2.0.0",
    "react-native-safe-area-context": "3.1.9",
    "react-native-screens": "~2.15.0",
    "react-native-svg": "12.1.0",
    "react-native-swiper": "^1.6.0",
    "react-native-tab-view": "^2.15.1",
    "react-native-web": "~0.13.12",
    "react-native-webview": "11.0.0",
    "react-navigation": "^4.4.0",
    "react-redux": "^7.2.0",
    "redux": "^4.0.5",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "rn-nodeify": "^10.2.0",
    "sentry-expo": "^3.0.3",
    "tailwind-rn": "^1.1.1",
    "top-bar-nav": "^1.2.2",
    "uuidv4": "^6.2.3"
  },

I have the exact same problem.

I’m Using managed app, EXPO SDK 40

Have tried: Removing location from from package.lock, and node modules

Nothing works, er have released the app on IOS, but are hold up at android because of this. Please help.

1 Like

Don’t do that.

What do you have in the android section of your app.json?

You should have something like the following examples:

(if you need nothing other than the things that Expo requires)

    "android": {
      ...
      "permissions": []
    }

or:

(if you need the camera and audio recording)

    "android": {
      ...
      "permissions": ["CAMERA", "RECORD_AUDIO"]
    }

Hi,

We are using
“android”: {
…“permissions”: [“NOTIFICATIONS”, “CAMERA”, “CONTACTS”, “MEDIA_LIBRARY”, “RECORD_AUDIO”],
…}

Do you have any more updates here? Looks like many people are encountering this issue.

I am having the same issue. Not being able to upload to Google Play, but Apple Store is fine. Have also tried to delete expo-location from package-lock, but it still does not work ("your background location permission declaration needs to be updated

  1. Are you using managed or bare app?

  2. What SDK version do you use?

  3. What packages do you use? (e.g. list your package.json)

  4. What is the output of aapt2 d permissions path/to/app.apk (See this installation/usage guide] of aapt2)

  5. What is the name of your app (e.g. @acme/app)

Hey, I have the same problem! This is urgent for me, because I already have the app built and published with Expo 40 on IOS, but now it seems that i have to degrade to Expo 39 to be able to build and publish to google play. This means I can’t use expo publish for hotfixes, which I’m highly reliant on right now.

Also will I still get denied (cuz of background location) if I only have this?

      "permissions": [
        "ACCESS_COARSE_LOCATION",
        "ACCESS_FINE_LOCATION",
        "CAMERA"
      ]

I just need accurate location while in foreground…

2 Likes