react-native-geolocation icon indicating copy to clipboard operation
react-native-geolocation copied to clipboard

NativeModule.RNCGeolocation is null - RN 0.61.1

Open zyonnetworks opened this issue 5 years ago • 18 comments

Environment

System: OS: macOS Mojave 10.14.6 CPU: (12) x64 Intel(R) Core(TM) 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

zyonnetworks avatar Oct 11 '19 18:10 zyonnetworks

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

stefanoTron avatar Oct 14 '19 07:10 stefanoTron

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

aminosman avatar Oct 17 '19 04:10 aminosman

Getting the same error,

macOS Catalina 10.15 iOS 11.1 Xcode 11.1

"react": "16.8.6", "react-native": "^0.59.5", "@react-native-community/geolocation": "^2.0.2",

my Podfile pod 'react-native-geolocation', :path => '../node_modules/@react-native-community/geolocation'

adeanugerah89 avatar Oct 21 '19 10:10 adeanugerah89

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

aminosman avatar Oct 21 '19 16:10 aminosman

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

adeanugerah89 avatar Oct 22 '19 03:10 adeanugerah89

Getting the same error on 0.61 (android)

spyshower avatar Oct 24 '19 12:10 spyshower

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"

adeanugerah89 avatar Oct 25 '19 07:10 adeanugerah89

yarn add @react-native-community/[email protected] react-native link @react-native-community/geolocation

Worked for me too.

josegamboa avatar Oct 29 '19 11:10 josegamboa

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?

tonygentilcore avatar Nov 30 '19 06:11 tonygentilcore

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

annieneedscoffee avatar Dec 04 '19 06:12 annieneedscoffee

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!

DiegoArrieta avatar Dec 15 '19 19:12 DiegoArrieta

i try all this solution and still have the same issue:

i make an import in my component Map.js : import Geolocation from '@react-native-community/geolocation';

i also install dependencies and downgrade @react-native-community/geolocation to 1.4.2 : "dependencies": { "@react-native-community/geolocation": "^1.4.2", "@react-native-community/masked-view": "0.1.6", "@react-navigation/drawer": "^5.5.0", "@react-navigation/native": "^5.1.5", "@react-navigation/stack": "^5.2.10" } And then make a link ; react-native link @react-native-community/geolocation But i also have the same error

i am making test with expo. Someone can help me please?

Genius237 avatar Apr 25 '20 12:04 Genius237

Getting the same error on 0.61 (android)

cd android gradlew clean

BuffonBLR avatar Jun 03 '20 19:06 BuffonBLR

I got around this by using react-native-location instead. Hope it helps. Windows/Android

Update: after installing react-native-location i was able to properly install and use react-native-Geolocation. It seems that Geolocation uses a native location api that, for some reason, and for some of us, it's like it doesn't exist. Installing react-native-location package installs some of this native api functions. So, after installing it, Geolocation package now runs smoothly.

Ro-F avatar Jun 05 '20 14:06 Ro-F

i try all this solution and still have the same issue:

i make an import in my component Map.js : import Geolocation from '@react-native-community/geolocation';

i also install dependencies and downgrade @react-native-community/geolocation to 1.4.2 : "dependencies": { "@react-native-community/geolocation": "^1.4.2", "@react-native-community/masked-view": "0.1.6", "@react-navigation/drawer": "^5.5.0", "@react-navigation/native": "^5.1.5", "@react-navigation/stack": "^5.2.10" } And then make a link ; react-native link @react-native-community/geolocation But i also have the same error

i am making test with expo. Someone can help me please?

@Genius237 , i have the same issue with expo , have you managed to solve the issue?

pmahan00 avatar Aug 06 '20 21:08 pmahan00

Have you tried to use react-native-location instead?

Ro-F avatar Aug 07 '20 08:08 Ro-F

I ended up using Expo's native API (expo install expo-location), as I am using expo already, and I do not have the Ios/Android folders. No trouble so far.

claugf avatar Nov 18 '20 03:11 claugf

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!

rogeriocassares avatar Feb 04 '21 16:02 rogeriocassares