react-native-netinfo: NativeModule.RNCNetInfo is null

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
      Memory: 350.61 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.12.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 19, 21, 23, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.2, 26.0.3, 27.0.3, 28.0.3
        System Images: android-19 | Google APIs ARM EABI v7a, android-21 | Google APIs ARM EABI v7a, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 2.3 AI-162.4069837
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.4 => 0.59.4 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Platforms

Versions

  • Android: 7.1.1
  • iOS: 12.1
  • react-native-netinfo: 2.0.1
  • react-native: 0.59.4
  • react: 16.8.3

Description

Just used yarn to add the package, and I am getting this error. I have followed the instructions suggested in the message. I am not using CocoaPods. Screen Shot 2019-04-14 at 4 34 22 PM

Reproducible Demo

Simply importing the library as described in the README documentation produces the error.

import NetInfo from '@react-native-community/netinfo';

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 40 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Any solution with auto-linking on react-native 0.61.1? The same issue coming.

@ryekerjh Hey! I have installed version 2.0.2 and linked it again using react-native link @react-native-community/netinfo that linked it successfully but didn’t work while I was building the app from xcode. So I manually dragged RNCNetInfo.xcodeproj (which is located at node_modules/@react-native-community/netinfo/ios/RNCNetInfo.xcodeproj) into root of xcode project. And after that go to build phase in xcode and click Link binary with libraries and add libRNCNetInfo.a there. That worked for me

I installed the most recent version (2.0.3) and went back and installed 2.0.2 (npm install --save @react-native-community/netinfo@2.0.2) and I am getting the same error. Is there anything I may be missing?

I am using “react-native”: “0.62.2”, “@react-native-community/netinfo”: “^5.9.2”, distributionUrl=https://services.gradle.org/distributions/gradle-6.5-all.zip

I am getting this error “NativeModule.RNCNetInfo is null” in android

I tried with manual linking no use.

Anyone, please help

@emersonhsieh read that second link I sent very carefully https://github.com/facebook/react-native/blob/master/template/ios/Podfile#L78

It does not contain the characters ‘unimodules’

Got it, I’ll add those lines manually to the Podfile since Expo did not generate them on ejection. Thank you so much!

Same problem here with react-native 0.61.5. Unable to use this module with auto-linking.

This issue still has I’m testing on android 9.

npx react-native-clean-project clean-project-auto

this happens all the time for react-native-device-info (I maintain there) and that command above frequently clears things up (except when it doesn’t, but doesn’t hurt to try)

the module definitely works with auto-linking.

@sagargulati

I recommend unlink everything that you do manually related this dependency and add the following line in your Podfile. pod ‘react-native-netinfo’, :path => ‘…/node_modules/@react-native-community/netinfo’

Then pod install and it should work.

Rebuilding the app again solved the issue for me.

Uninstall the app first, run the command “cd android && gradlew clean && cd…” then run “react-native run-android”.

@ngoctan95 This is working if you have the library linked correctly. If you search for RNCNetInfo in the issues there are already lots of discussions for the different scenarios where linking was not performed correctly. It’s 99% certain that your issue is one of those. Take a look through them and if it really isn’t one of those, open a new issue with as much information as you can, including why it’s not any of the previously mentioned issues.

https://github.com/react-native-community/react-native-netinfo/issues?utf8=✓&q=RNCNetInfo

@matt-oakes Oh I did not see the manual, thanks, that was the problem. Havent linked properly!

@guptayash Also worked for me. Libraries–RCTNetInfo.xcodeproj–Products–libRNCNetInfo.a drag to targets–Build Phases --Link Binary With Libraries.

@matt-oakes I just installed 2.0.2 and it works, thanks for the fast fix!

🎉 This issue has been resolved in version 2.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

👋 Thanks for reporting this. I have an idea what this is and will work to have a fix out by tomorrow