So:
I have React Native project made trough Expo. It has couple of views, airbnb mapView and stuff like that. It was previously pure react native project (Made before create-react-native-app was even a thing) and I lately moved it to expo. Almost everything works fine. The transformation to expo was perfectly fine for iOS and everything works as expected on that side. BUT i get really weird error when trying to launch the app on android phone.
Attempt to invoke interface method 'boolean abi20_0_0.com.facebook.react.bridge.ReadableMap.hasKey(java.lang.String)' on a null object reference
I think it has something to do with the actual process of finding the location not really the mapView, but the only thing i changed was:
import MapView from 'react-native-maps';
to
import { MapView } from 'expo';
This is the actual code used to find location:
componentDidMount() {
navigator.geolocation.getCurrentPosition(
(position) => {
this.setState({
region: {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
latitudeDelta: LATITUDE_DELTA,
longitudeDelta: LONGITUDE_DELTA
},
lat : position.coords.latitude,
lon : position.coords.longitude,
cords : {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
}
});
},
(error) => alert(error.message),
{enableHighAccuracy: true, timeout: 20000, maximumAge: 1000}
);
this.watchID = navigator.geolocation.watchPosition(
(position) => {
this.setState({
cords : {
latitude: position.coords.latitude,
longitude: position.coords.longitude,
},
lat : position.coords.latitude,
lon : position.coords.longitude,
});
});
}
It still works normally on the old android version without expo and it works on the new iOS version made with expo.
package.json depencies
"dependencies": {
"expo": "^20.0.0",
"firebase": "^4.3.0",
"react": "16.0.0-alpha.12",
"react-native": "https://github.com/expo/react-native/archive/sdk-20.0.0.tar.gz",
"react-navigation": "^1.0.0-beta.11"
}
I founded one other question on this exactly same problem: watchPosition fails with react native expo He had ended up to the same conclusion as I but had very little info on his question and no answers/comments so I decided to make my own question.