Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android react-native avoiding "Background location access not declared" in Google approval process

Okay, so Google is telling us "Background location access not declared" and not letting us publish our app. We have no use for background location, so we're trying to elimiate it completely.

Of course my manifest doesn't have it:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
    <uses-permission android:name="com.android.vending.BILLING" />
    <uses-feature android:name="android.hardware.location.gps"/>

I've searched absolutely everywhere for anything that could be adding ACCESS_BACKGROUND_LOCATION to our app, and found nothing.

Using the silver searcher:

ag ACCESS_BACKGROUND_LOCATION .

I've exampined the blame report for a clue, and worked backwards on anything with the word 'background', to no avail: android/app/build/intermediates/manifest_merge_blame_file/myAppRelease/manifest-merger-blame-myapp-release-report.txt

I did find some extra permissions though:

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

But I don't see any red flags there..

I've tried the node remove option:

<manifest ...xmlns:tools="http://schemas.android.com/tools"...>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" tools:node="remove" />

But nothing.

I've also run aapt2

$ aapt2 d permissions android/app/build/outputs/apk/myapp/release/app-myapp-release.apk
package: com.myapp
uses-permission: name='android.permission.INTERNET'
uses-permission: name='android.permission.ACCESS_COARSE_LOCATION'
uses-permission: name='android.permission.ACCESS_FINE_LOCATION'
uses-permission: name='android.permission.SYSTEM_ALERT_WINDOW'
uses-permission: name='com.android.vending.BILLING'
uses-permission: name='android.permission.ACCESS_NETWORK_STATE'
uses-permission: name='android.permission.ACCESS_WIFI_STATE'
uses-permission: name='android.permission.WAKE_LOCK'

Which doesn't tell me much more..

I've also watched the whole youtube video google posted regarding background positions, read the official docs, and checked every stack overflow post on this - but they just recommend the steps I've already taken.

It's an exhausting process! I'm exhausted. My best guess is that one our dependencies is the problem, but I have no good clues as to which one it could be.

Would really appreciate some fresh eyes.. maybe someones encountered this with one of these packages below and is just going to be like, that's the one! Delete it!

Otherwise it's back to desperate searching and brute force rebuilds on minimal information..

  "dependencies": {
    "@mapbox/geo-viewport": "0.4.1",
    "@mapbox/geojson-extent": "0.3.2",
    "@mapbox/polyline": "1.1.1",
    "@ptomasroos/react-native-multi-slider": "1.0.0",
    "@react-native-community/async-storage": "1.12.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "4.7.0",
    "@react-native-mapbox-gl/maps": "7.0.8",
    "@sentry/react-native": "1.8.2",
    "@turf/along": "^6.0.1",
    "@turf/bearing": "^6.0.1",
    "@turf/distance": "^6.0.1",
    "@turf/helpers": "^6.1.4",
    "@turf/line-distance": "^4.7.3",
    "@turf/nearest": "^4.7.3",
    "check-node-version": "4.0.3",
    "deprecated-react-native-listview": "^0.0.6",
    "eslint-plugin-react": "7.21.2",
    "install": "^0.13.0",
    "npm": "6.14.8",
    "prop-types": "^15.6.0",
    "react": "16.11.0",
    "react-native": "0.62.2",
    "react-native-billing": "^3.0.0",
    "react-native-config": "^1.4.2",
    "react-native-elements": "^1.2.7",
    "react-native-gesture-handler": "1.8.0",
    "react-native-in-app-utils": "6.1.0",
    "react-native-linear-gradient": "^2.5.6",
    "react-native-mixpanel": "1.2.5",
    "react-native-rate": "1.0.9",
    "react-native-safe-area-context": "^3.1.8",
    "react-native-screens": "2.8.0",
    "react-native-splash-screen": "3.2.0",
    "react-native-sqlite-2": "1.7.0",
    "react-native-vector-icons": "^6.6.0",
    "react-native-webview": "10.9.3",
    "react-navigation": "4.0.10",
    "react-navigation-stack": "2.0.16",
    "url": "^0.11.0",
    "util": "0.12.3",
    "which-polygon": "2.2.0"
  },
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "eslint": "^6.8.0",
    "eslint-plugin-import": "2.22.1",
    "fs-extra": "^8.1.0",
    "jetifier": "1.6.6",
    "metro-react-native-babel-preset": "^0.58.0",
    "minimatch": "^3.0.4",
    "node-watch": "0.6.4",
    "rimraf": "2.7.1"
  }

Hopefully the right eyes sees this, or can point to something.. Thanks!

Update, got some more details from google:

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: https://developer.android.com/training/location/background) You should no longer see the Location declaration listed in console under App Content. If your are targeting Android 9 or older (SDK level 28 or lower): If you’re already using ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION, examine your code paths and restrict usage to foreground purposes only. (learn more: https://developer.android.com/training/location/background) In your console declaration, select “No” to the question “Does your app access location in the background in APKs or app bundles targeting Android 9 or older?

like image 421
Seth Avatar asked Feb 25 '21 03:02

Seth


1 Answers

I fixed this not by removing "ACCESS_BACKGROUND_LOCATION" from .js like grep -r "ACCESS_BACKGROUND_LOCATION" . | cut -c1-150 did, but by just removing "ACCESS_BACKGROUND_LOCATION" from .java like:

sed -i -e "s/.*ACCESS_BACKGROUND_LOCATION.*/return true;/g" node_modules/expo-location/android/src/main/java/expo/modules/location/LocationModule.java
like image 67
Li Zheng Avatar answered Oct 13 '22 21:10

Li Zheng