react-native-geolocation
react-native-geolocation copied to clipboard
NativeModule.RNCGeolocation is null - RN 0.61.1
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
I was having the same issue. But after stopping the packager, cleaning my build in Xcode, and then running pod install
it worked fine
Make sure you have pod 'react-native-geolocation', path: '../node_modules/@react-native-community/geolocation'
in your pod file
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'
This error + solution is for RN 0.60+. Did you react-native link react-native-geolocation
?
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
Getting the same error on 0.61 (android)
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"
yarn add @react-native-community/[email protected] react-native link @react-native-community/geolocation
Worked for me too.
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?
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:
- yarn remove @react-native-community/geolocation
- cd ios
- pod deintegrate
- navigate back to the project with ../
- npm install @react-native-community/geolocation --save
- cd ios
- pod install
- watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
- close terminal windows with this and metro bundler and anything else related to react native
- open a new window and react-native run-ios
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:
- yarn remove @react-native-community/geolocation
- cd ios
- pod deintegrate
- navigate back to the project with ../
- npm install @react-native-community/geolocation --save
- cd ios
- pod install
- watchman watch-del-all && rm -rf $TMPDIR/react-* && rm -rf node_modules/ && npm cache verify && npm install && npm start -- --reset-cache
- close terminal windows with this and metro bundler and anything else related to react native
- open a new window and react-native run-ios
this solutions rocks!!, thanks!
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?
Getting the same error on 0.61 (android)
cd android gradlew clean
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.
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?
Have you tried to use react-native-location instead?
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.
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!