react-native-geolocation-service: TypeError: null is not an object (evaluating 'RNFusedLocation.startObserving')
Geolocation.clearWatch(this.watchID);
this.watchID = Geolocation.watchPosition(
position => {
console.log("New position!");
},
error => console.log(error),
{
enableHighAccuracy: true,
timeout: 20000,
distanceFilter: 0
}
);
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 29 (7 by maintainers)
i got same issue. fixed with add this lines to android/build.gradle
“react-native”: “0.61.5”, “react-native-geolocation-service”: “^4.0.0”, “react-native-maps”: “^0.26.1”
Check These lines added in your MainApplication.java
import com.agontuk.RNFusedLocation.RNFusedLocationPackage;
add new RNFusedLocationPackage() in
@Override protected List<ReactPackage> getPackages() { return Arrays.<ReactPackage>asList( new MainReactPackage(), new MapsPackage(), new RNFusedLocationPackage()
It fixes my issue
It fixed for me after I did
react-native run-android
Had similar issue and this saved me within 5mins
[stackoverflow soluntion](https://stackoverflow.com/questions/56908771/typeerror-undefined-is-not-an-object-evaluating-navigator-geolocation-request)
I also receive this with getcurrentPosition:
Geolocation.getCurrentPosition( (position) => { console.log(position); }, (error) => { // See error code charts below. console.log(error.code, error.message); }, { enableHighAccuracy: false, timeout: 15000, maximumAge: 10000 } );
These are the packages.The error received is: ReactNativeJS ▶︎ Possible Unhandled Promise Rejection (id: 0): │ TypeError: null is not an object (evaluating ‘RNFusedLocation.getCurrentPosition’) │ getCurrentPosition$@http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:181123:32
Happy to provide more information as i’m at a bit of a loss on this now.
The solution I went with, which ended up being the easiest, was to just not use this at all. It has it’s pros and cons though.
@markwillis82 , can you look inside the
node_modules/react-native-geolocation-service
and upload the contents ofjs/index.js
andRNFusedLocationModule.java
inside android folder to pastebin or similar site ?Also make sure you added
new RNFusedLocationPackage()
inMainApplication.java