Bender
Bender

Reputation: 13

@react-native-community/geolocation:NativeModule.RNCGeolocation is null

I'm trying to use Geolocation on my React Native app (Ios, expo). I have installed react-native-community/geolocation, and when I import it I get this erro:

@react-native-community/geolocation:NativeModule.RNCGeolocation is null.

It asks me to run "react-native link @react-native-community/geolocation" in the project root, but when I do it it says: Calling react-native link [packageName] is deprecated in favor of autolinking.

I do not know what to do anymore. Can anyone help me with this? Please

Upvotes: 1

Views: 9184

Answers (2)

eclat_soft
eclat_soft

Reputation: 808

Adviced: To clean cache, delete node_module folder,

npm cache clean

rm -rf node_modules

If you have android folder cd android && ./gradlew clean

Then do an : npm install on your root project directory.

I did all but one thing you have to ensure is opening your project with Android studio, (the android folder of your project). And it does the gradle build along with several other linking AUTOMATICALLY.

However, Most of the times this doesnt come with your expo, so you have to generate the android and IOS folder using

expo prebuild.

Don't forget running your android folder in the android studio to build gradle for you and save you the stress.

Upvotes: 1

marcelofreires
marcelofreires

Reputation: 824

If you are using Expo, you can use the Location from Expo.

But if you want to use the @react-native-community/geolocation, since react-native 0.60 or higher the autolinking should configure the library for you automatically. But if use react-native 0.59 or lower, you must make a manual installation for iOS and Android when the react-native link doesn't work.

Upvotes: 2

Related Questions