Writing

Remove ACCESS_FINE_LOCATION from an Expo app that uses expo-location

By Mohamed Gado · · 2 min read

Nafis, my gold-price app, uses the phone's location for one thing: picking the user's country so it shows local prices. A country doesn't need GPS. So I wanted the Android build to ask for approximate location only, ACCESS_COARSE_LOCATION, and drop ACCESS_FINE_LOCATION.

The obvious edit was to delete FINE from android.permissions in app.json:

"permissions": ["android.permission.ACCESS_COARSE_LOCATION"]

I rebuilt, and FINE was still in the manifest.

Where FINE comes from#

expo-location adds it in two places, and neither one reads your permissions list.

1. The config plugin. At the end of expo-location/plugin/build/withLocation.js (expo-location 58.0.22), the plugin always adds both:

return AndroidConfig.Permissions.withPermissions(config, [
  // Note: these are already added in the library AndroidManifest.xml and so
  // are not required here, we may want to remove them in the future.
  'android.permission.ACCESS_COARSE_LOCATION',
  'android.permission.ACCESS_FINE_LOCATION',
  // ...background, foreground service and motion permissions, only when enabled
].filter(Boolean))

2. The library's own manifest. As that comment says, expo-location/android/src/main/AndroidManifest.xml declares the same two permissions:

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Android's manifest merger combines every library manifest into your app's. So even if you edited the generated AndroidManifest.xml by hand, the merge would add FINE back from the library. Removing it from your own list can't win against either source.

The fix: blockedPermissions#

Expo has a separate setting for this, android.blockedPermissions:

{
  "expo": {
    "android": {
      "permissions": ["android.permission.ACCESS_COARSE_LOCATION"],
      "blockedPermissions": ["android.permission.ACCESS_FINE_LOCATION"]
    }
  }
}

A blocked permission isn't just left out. Expo writes it into your app manifest with a removal marker for the manifest merger:

<uses-permission
  android:name="android.permission.ACCESS_FINE_LOCATION"
  tools:node="remove" />

tools:node="remove" tells the merger to drop that element from the final manifest, whichever library contributed it. That handles both sources at once.

Check it without a full build#

You don't need a release build to see the result. Expo can print the generated config:

npx expo config --type introspect

Look for ACCESS_FINE_LOCATION in the Android manifest section. It should appear once, with tools:node="remove". After a real build, you can check the merged result in the APK:

aapt2 dump permissions app-release.apk

FINE should be gone, and COARSE should still be listed.

I also pinned it with a small test that reads app.json and fails if FINE ever leaves blockedPermissions or shows up in permissions. Permission lists tend to get "cleaned up" months later by someone who doesn't know why the block is there.

What changes in the app#

The JS side keeps working. requestForegroundPermissionsAsync() still asks for location. On Android, expo-location bases the foreground status on COARSE and reports the accuracy separately (from LocationModule.kt):

var accuracy = "none"
if (locationPermission.granted) accuracy = "coarse"
if (fineLocationPermission.granted) accuracy = "fine"

With FINE removed, a granted request comes back with status: 'granted' and android.accuracy: 'coarse'. On Android 12 and later, the system dialog only offers approximate location, so the user sees a smaller request. The fixes you get are approximate, which is fine for a country lookup and not fine for turn-by-turn directions. Check what your app does with the coordinates before you drop FINE.

Two mistakes I made on the way#

  • I read a still-listed FINE as "blockedPermissions doesn't work." The app.json edit had actually failed on a line-ending mismatch, so the check was reading the unedited file. Confirm your edit landed before you blame the setting.
  • I trusted an empty search. My first grep for permission strings used a glob that matched no files, so it returned nothing and looked clean. Before you trust a search that finds nothing, make sure it can find something.