React-native-geolocation-service: TypeError: null is not an object (evaluating 'RNFusedLocation.startObserving')

Created on 22 Jun 2019  Â·  23Comments  Â·  Source: Agontuk/react-native-geolocation-service

    Geolocation.clearWatch(this.watchID);
    this.watchID = Geolocation.watchPosition(
      position => {
        console.log("New position!");
      },
      error => console.log(error),
      {
        enableHighAccuracy: true,
        timeout: 20000,
        distanceFilter: 0
      }
    );

Most helpful comment

"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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new MapsPackage(),
new RNFusedLocationPackage()

        );
    }

It fixes my issue

All 23 comments

Please provide more details like package version, RN version etc.

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.

"react-native": "0.60.4",
"react-native-geolocation-service": "^3.0.0",

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.

@markwillis82 , can you look inside the node_modules/react-native-geolocation-service and upload the contents of js/index.js and RNFusedLocationModule.java inside android folder to pastebin or similar site ?

Also make sure you added new RNFusedLocationPackage() in MainApplication.java

@markwillis82 , can you look inside the node_modules/react-native-geolocation-service and upload the contents of js/index.js and RNFusedLocationModule.java inside android folder to pastebin or similar site ?

Also make sure you added new RNFusedLocationPackage() in MainApplication.java

Do you need to do that on react-native version 0.60+?

@markwillis82 , can you look inside the node_modules/react-native-geolocation-service and upload the contents of js/index.js and RNFusedLocationModule.java inside android folder to pastebin or similar site ?
Also make sure you added new RNFusedLocationPackage() in MainApplication.java

Do you need to do that on react-native version 0.60+?

No.

It fixed for me after I did react-native run-android

I am still getting this. Any update?

Any updates? I'm still getting this.

I had a similar issue all i had to do was run react-native link react-native-geolocation-service and then added new RNFusedLocationPackage() in MainApplication.java

Try the manual setup if it does not work out of the box. If you're updating to 0.60 from lower versions and already have manual setup of other libraries, then you probably have to setup this library manually too.

issue is not solved

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)

@coolprinze As also stated in the readme.

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.

"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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new MapsPackage(),
new RNFusedLocationPackage()

        );
    }

It fixes my issue

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)

this solution solved my issue

"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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new MapsPackage(),
new RNFusedLocationPackage()

        );
    }

It fixes my issue

Not working for me, did we still link manually in RN 0.60 ?

No

On Thu, 27 Feb 2020, 16:06 Dwi Wijonarko, notifications@github.com wrote:

"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 https://github.com/override
protected List getPackages() {
return Arrays.asList(
new MainReactPackage(),
new MapsPackage(),
new RNFusedLocationPackage()

    );
}

It fixes my issue

Not working for me, did we still link manually in RN 0.60 ?

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Agontuk/react-native-geolocation-service/issues/84?email_source=notifications&email_token=ACR6SRBOPCNYWKTSHTJ3FVLRE6GBXA5CNFSM4H2XONW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENDXXFY#issuecomment-591887255,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACR6SRBWAV5MXXNLCMC6QSDRE6GBXANCNFSM4H2XONWQ
.

Not working for me, did we still link manually in RN 0.60 ?

This question has been answered a million times and is in the README.md

Closing this, as this is setup related issue.

The above mentioned solutions didn't work for me... Is there any other solutions?

"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 getPackages() {
return Arrays.asList(
new MainReactPackage(),
new MapsPackage(),
new RNFusedLocationPackage()

        );
    }

It fixes my issue

This didn't work for me

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)

react-native-community/geolocation Didn't work for me, that's why I switched to react-native-geolocation-service and now this is also not working

Was this page helpful?
0 / 5 - 0 ratings