react-native-geolocation: NativeModule.RNCGeolocation is null - RN 0.61.1

Environment

System: OS: macOS Mojave 10.14.6 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Memory: 387.96 MB / 32.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node Yarn: 1.17.3 - /usr/local/bin/yarn npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 12.4, macOS 10.14, tvOS 12.4, watchOS 5.3 Android SDK: API Levels: 23, 26, 27, 28 Build Tools: 27.0.3, 28.0.3 System Images: android-27 | Google Play Intel x86 Atom IDEs: Android Studio: 3.2 AI-181.5540.7.32.5056338 Xcode: 10.3/10G8 - /usr/bin/xcodebuild npmPackages: react: 16.9.0 => 16.9.0 react-native: 0.61.1 => 0.61.1 npmGlobalPackages: react-native-cli: 2.0.1

Platforms

Both

Versions

  • Android:
  • iOS:
  • react-native-geolocation: 2.0.2
  • react-native: 0.61.1
  • react: 16.9.0

Description

When running app on RN 0.61.1, I encounter this error in the debug console Error: @react-native-community/geolocation: NativeModule.RNCGeolocation is null.

Reproducible Demo

Run project after yarn and pod install, open debug console

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 6
  • Comments: 18

Most upvoted comments

Same issue here on android, react-native-geolocation: 2.0.2, react-native: 0.61.5.

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

Has anyone found a fix/workaround?

Make sure you have pod 'react-native-geolocation', path: '../node_modules/@react-native-community/geolocation' in your pod file

Getting the same error on 0.61 (android)

Hi @zyonnetworks !

On Android device, i have just tried to use the 'react-native-geolocation-service' and it really worked for me!

yarn add react-native-geolocation-service

As the API format is really similar, I had just to change the import line. Please, check it out!

// import Geolocation from '@react-native-community/geolocation';
import Geolocation from 'react-native-geolocation-service';

Thats all! Thanks!

For me building failed after I installed it with yarn, but removing it, cleaning everything, and then reinstalling with npm instead fixed it for me. Here are the steps I took:

  1. yarn remove @react-native-community/geolocation
  2. cd ios
  3. pod deintegrate
  4. navigate back to the project with …/
  5. npm install @react-native-community/geolocation --save
  6. cd ios
  7. pod install
  8. watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start – --reset-cache
  9. close terminal windows with this and metro bundler and anything else related to react native
  10. open a new window and react-native run-ios

This error + solution is for RN 0.60+. Did you react-native link react-native-geolocation?

already did ‘react-native link @react-native-community/geolocation’ , I also tried manually linked, but still get the same error

problem solved, just downgrade the version “@react-native-community/geolocation”: “1.4.2”

I was having the same issue. But after stopping the packager, cleaning my build in Xcode, and then running pod install it worked fine

Getting the same error on 0.61 (android)

cd android gradlew clean

For me building failed after I installed it with yarn, but removing it, cleaning everything, and then reinstalling with npm instead fixed it for me. Here are the steps I took:

  1. yarn remove @react-native-community/geolocation
  2. cd ios
  3. pod deintegrate
  4. navigate back to the project with …/
  5. npm install @react-native-community/geolocation --save
  6. cd ios
  7. pod install
  8. watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start – --reset-cache
  9. close terminal windows with this and metro bundler and anything else related to react native
  10. open a new window and react-native run-ios

this solutions rocks!!, thanks!