Only ACCESS_COARSE_LOCATION not working for lowest accuracy location

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

I was trying to reduce permissions to minimum. I used to have The ACCESS_COARSE_LOCATION and also ACCESS_FINE_LOCATION. However I never used fine location. So I removed it. I did a build and installed locally and it worked fine, but after releasing to store it’s not working. These are the only location calls I do. Anyone have any ideas why its not working with just coarse permission?

function getLocation() {

try {
 return await Location.getLastKnownPositionAsync();
} catch (error) {
  return await Location.getCurrentPositionAsync({
      accuracy: Location.LocationAccuracy.Lowest
  });
}

}

Oh man I think I found it, this function call here in expo java module is ensuring it has FINE permissions access - for getCurrentPositionAsync: expo/LocationModule.java at cdc8e944c5c189b4d52c3c79fae3658c7469ee85 · expo/expo · GitHub and for getLastKnownPositionAsync: expo/LocationModule.java at cdc8e944c5c189b4d52c3c79fae3658c7469ee85 · expo/expo · GitHub

Is this correct? Maybe its not needed for low accuracy and this can be changed?

You’re right about that. Whether ACCESS_FINE_LOCATION is actually needed, I don’t know.

I’d be inclined to try this:

diff --git android/versioned-abis/expoview-abi42_0_0/src/main/java/abi42_0_0/expo/modules/location/LocationModule.java android/versioned-abis/expoview-abi42_0_0/src/main/java/abi42_0_0/expo/modules/location/LocationModule.java
index 122f0a8e8e..aab9ec974b 100644
--- android/versioned-abis/expoview-abi42_0_0/src/main/java/abi42_0_0/expo/modules/location/LocationModule.java
+++ android/versioned-abis/expoview-abi42_0_0/src/main/java/abi42_0_0/expo/modules/location/LocationModule.java
@@ -583,10 +583,15 @@ public class LocationModule extends ExportedModule implements LifecycleEventList
   //region private methods
 
   /**
-   * Checks whether all required permissions have been granted by the user.
+   * Checks whether the user has granted either coarse or fine location permissions.
    */
   private boolean isMissingForegroundPermissions() {
-    return mPermissionsManager == null || !mPermissionsManager.hasGrantedPermissions(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION);
+    if (mPermissionsManager == null) {
+      return true;
+    }
+    boolean canAccessFineLocation = mPermissionsManager.hasGrantedPermissions(Manifest.permission.ACCESS_FINE_LOCATION);
+    boolean canAccessCoarseLocation = mPermissionsManager.hasGrantedPermissions(Manifest.permission.ACCESS_COARSE_LOCATION);
+    return !canAccessFineLocation && !canAccessCoarseLocation;
   }
 
   /**

Maybe try it with patch-package to see if it works?

1 Like

Oo thank you I will try this! I’m not on EAS yet, still on SDK 40 on this app. But I’ll try this on my other app which is EAS. Thanks very much!

If it works you might want to create an issue on GitHub with the details.

Oh will do for sure! Didn’t get to test yet.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.