react-native-netinfo: @react-native-community/netinfo: NativeModule.RNCNetInfo is null on some android devices only
Environment
System:
OS: macOS 10.14.4
CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
Memory: 38.43 MB / 8.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.11.0 - ~/.nvm/versions/node/v10.11.0/bin/node
Yarn: 1.12.3 - ~/.nvm/versions/node/v10.11.0/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.11.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 26, 28, 29
Build Tools: 28.0.3
System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom_64, android-29 | Google Play Intel x86 Atom, android-29 | Google Play Intel x86 Atom_64
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.5791312
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: ^0.60.3 => 0.60.5
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.59.1
Platforms
This occur on some android devices (android 6,7,8,9) No error found on iOS, Some other android devices still work without this error.
Versions
- Android: 6,7,8,9
- react-native-netinfo: @react-native-community/netinfo@4.2.2
- react-native@0.60.5
- react@16.8.6
Description
The error I’ve got from Fabric:
Fatal Exception: com.facebook.react.common.JavascriptException: @react-native-community/netinfo: NativeModule.RNCNetInfo is null. To fix this issue try these steps:
• Run `react-native link @react-native-community/netinfo` in the project root.
• Rebuild and re-run the app.
• If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.
• Check that the library was linked correctly when you used the link command by running through the manual installation instructions in the README.
* If you are getting this error while unit testing you need to mock the native module. Follow the guide in the README.
If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-netinfo, stack:
<unknown>@498:410
v@2:1474
<unknown>@497:184
v@2:1474
<unknown>@496:171
v@2:1474
<unknown>@493:431
v@2:1474
<unknown>@492:144
v@2:1474
<unknown>@488:156
v@2:1474
<unknown>@341:342
v@2:1474
<unknown>@340:219
v@2:1474
<unknown>@6:58
v@2:1474
d@2:876
global code@1421:4
at com.facebook.react.modules.core.ExceptionsManagerModule.showOrThrowError + 54(ExceptionsManagerModule.java:54)
at com.facebook.react.modules.core.ExceptionsManagerModule.reportFatalException + 38(ExceptionsManagerModule.java:38)
at java.lang.reflect.Method.invoke(Method.java)
at com.facebook.react.bridge.JavaMethodWrapper.invoke + 372(JavaMethodWrapper.java:372)
at com.facebook.react.bridge.JavaModuleWrapper.invoke + 158(JavaModuleWrapper.java:158)
at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java)
at android.os.Handler.handleCallback + 873(Handler.java:873)
at android.os.Handler.dispatchMessage + 99(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage + 29(MessageQueueThreadHandler.java:29)
at android.os.Looper.loop + 214(Looper.java:214)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run + 232(MessageQueueThreadImpl.java:232)
at java.lang.Thread.run + 764(Thread.java:764)
Reproducible Demo
Can not create the minimal demo because our app is on production
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 26 (1 by maintainers)
Ever since upgrading react native to 0.61.2 I am seeing this error on my app as well. Can’t say what’s going on.
I ran into this issue when upgrading from React native 0.61 to 0.62. I followed the upgrade helper and updated all relevant sections of the config, but the issue remained.
In the end, I resorted to
react-native link @react-native-community/netinfo, but the link it created needed modifying before it would work. I had to change a dependency line inandroid/app/build.gradlefrom:to:
This has happened to me since upgrading to 0.62.2. It happens with every library now. I managed to get it working by manually linking the library.
It seems there were some problems that showed up after upgrading from 0.59.8 to 0.61.2. I managed to solve it by replacing my android directory with the android directory of a new react native cli project.
Just remember that doing this will reset your android projects settings, icons, etc. Also make sure you create the app using the same app name.
Edit: @fgagneten, here’s how i did it.
Create new react native project:
Replace the android directory in the root of your project with the android directory in the new react native project you just created. You might want to make a backup before you do this.
(Optional) if you need to link assets:
Start Android emulator.
Run app: