I am developing a location-based app and I am using expo bare flow after I ejected my project. I tested my project in an android studio emulator with android 8,7 it worked fine but when I tested in android 9 emulator I got that error even I grant the location permission.
this a part of my code :`
getLocationAsync = async () => {
let { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status !== 'granted') {
this.setState({
errorMessage: 'Permission to access location was denied',
});
}
Location.watchPositionAsync({enableHighAccuracy:true},async (location)=>{
// console.log("Driver current lat long is",location)
if(location) {
var pos = {
latitude: location.coords.latitude,
longitude: location.coords.longitude,
};
this.setState({ myLocation: pos })
var curuser = firebase.auth().currentUser.uid;
if(pos){
var latlng = pos.latitude + ',' + pos.longitude;
try {
const response = await fetch('https://maps.googleapis.com/maps/api/geocode/json?latlng=' + latlng + '&key=' + google_map_key);
const responseJson = await response.json();
if (responseJson.results[0] && responseJson.results[0].formatted_address) {
/////
}
else {
alert(languageJSON.api_error);
}
}
catch (error) {
console.error(error);
}
}
}
});
}`