1

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

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.