I have just upgraded my app from Expo SDK 37.0.0 to 38.0.0. The app works fine on iOS but on Android I get the following warning and the app doesn't geolocate me on the map.
Development environment :
Expected result : The app should geolocate me (the user) based on my position. Actual result : The app doesn't geolocate me (the user) based on my position. Warning :
[Unhandled promise rejection: Error: Location provider is unavailable. Make sure that location services are enabled.]
What have I tried so far?
Ran expo upgrade once more to ensure that all of your packages are set to the correct version.
Deleted package-lock.json and node_modules and ran npm install.
Set Location.getCurrentPositionAsync({accuracy:Location.Accuracy.High})
Set Location.getCurrentPositionAsync({ enableHighAccuracy: true })
import * as Location from 'expo-location';
import * as Permissions from 'expo-permissions';
async _getLocationAsync() {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
/* If user hasn't granted permission to geolocate himself herself */
Alert.alert(
"User location not detected",
"You haven't granted permission to detect your location.",
[{ text: 'OK', onPress: () => console.log('OK Pressed') }]
);
}
let location = await Location.getCurrentPositionAsync({ accuracy: Location.Accuracy.High });
this.setState({
userLat: location.coords.latitude,
userLng: location.coords.longitude,
navGeoStatus: true,
lat: location.coords.latitude,
lng: location.coords.longitude
});
}```
If anyone is still fighting with this problem - please check if you have added:
"android": {
"permissions": ["ACCESS_BACKGROUND_LOCATION"]
},
in your app.json
file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With