App is getting crashed in android when it requesting for location permission.
This is code the im running
Permissions.request('location', 'whenInUse').then(async (res) => {
console.log("res",res);
if(res == "denied"){
this.setState({
locationGranted: false
})
}
});
And it throws the error
java.lang.SecurityException: Looks like the app doesn't have the permission to access location. Add the following line to your app's AndroidManifest.xml:
LocationModule.java:236 - com.facebook.react.modules.location.LocationModule.throwLocationPermissionMissing
But i added the location permission in manifest file
Can you publish the content of your AndroidManifest.xml?
This is my Manifest file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
@MugeshM Try adding
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Did you solve this @MugeshM ?
This happens even if both permissions are in the manifest file (ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION).
Any solution on this issue ?
I think we have seen this happen to us, reported via Sentry monitoring.
SecurityExceptioncom.facebook.react.modules.location.LocationModule in throwLocationPermissionMissing
fatalLooks like the app doesn't have the permission to access location. Add the following line to your app's AndroidManifest.xml: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
But we really do have it in AndroidManifest.xml, and we do not have ACCESS_COARSE_LOCATION.
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
our code is like
const response = await RNPermissions.request('location');
first this module only look for this permission for location, location: PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION, not the COARSE,
in my code at check everytime if permission doesn't return "authorized" then I'm send it to request.
It works, but I'm using the react native api
fwiw, this sounds possibly related/relevant: https://github.com/facebook/react-native/pull/10291
I encounter same problem,
just change
compileSdkVersion
buildToolsVersion
to
compileSdkVersion 25
buildToolsVersion "25.0.1"
and
implementation "com.android.support:appcompat-v7:25.0.1"
@joshuadiezmo unfortunately that is not a good solution for us (and i suspect for many other devs here) because that pushes the permissions UX back to the old "everything at install time" behaviour, i think?
yeah, its not a good solution, but its working on me.
~Any other ideas? This is still an issue and downgrading is not an option in our case.~
In my case the cause was my own stupidity. I for some reason expected the result to be a boolean, but it's a string. Leaving this here as a monument to my own stupidity and hopefully help for others.
any solution ?!
Any Solution?? I am facing the same problem
I'm trying to replace with PermissionAndroid but it still crash on production.
RN: 0.55.4
Any help pls?
Any lead to this issue? I am facing the same issue. Tried all the solutions provided above but still couldn't solve it.
I am closing this since this issue does not exists anymore with the 2.0.0 release.
Most helpful comment
This happens even if both permissions are in the manifest file (
ACCESS_COARSE_LOCATIONandACCESS_FINE_LOCATION).