react-native-device-info: RNDeviceInfo is null

Bug

Trying to run a clean project on Android causes the red error screen with the message:

Error: @react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null.

Environment info

React native info output:

System:
    OS: macOS Mojave 10.14.6
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 154.95 MB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 10.14.1 - ~/.nvm/versions/node/v10.14.1/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v10.14.1/bin/yarn
    npm: 6.11.3 - ~/.nvm/versions/node/v10.14.1/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
      API Levels: 26, 28, 29
      Build Tools: 28.0.3, 29.0.2
      System Images: android-29 | Intel x86 Atom, android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, 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: 11.0/11A420a - /usr/bin/xcodebuild
  npmPackages:
    react: 16.9.0 => 16.9.0
    react-native: 0.61.1 => 0.61.1

Library version: 3.1.4

Steps To Reproduce

  1. create clean project with (RN 0.61.1):
react-native init test
  1. yarn add react-native-device-info
  2. cd ios && pod install && cd … (with success message)
  3. add code:
import DeviceInfo from 'react-native-device-info';
...
DeviceInfo.isTablet().then(isTablet => {
    console.log(isTablet);
});
  1. Project presents red screen on Android.
  2. Project runs just fine on iOS.

(Oddly enough, if I perform the manual linking steps [despite running RN0.61.1] the Android project runs fine then)

Describe what you expected to happen:

  1. Both iOS and Android runs should fine and log wether if the device is a tablet or not.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16

Most upvoted comments

Im having an issue trying to use a private repo with the new testing-library for react-native (.59)

My hunch is that if we can upgrade to .61 the issue will go away, ive tried performing manual link, xcode build, pod install etc

posting me-toos does not work. I need someone to clone this repo, run the example, and tell me it does not work.

Here’s what I did

git clone git@github.com:react-native-community/react-native-device-info.git
cd react-native-device-info
./refresh-example.sh
cd example
yarn ios

It works. Any evidence to the contrary I/we are all over it. In the meantime, something is wrong with project integration at the project-specific level and that’s not something we can control or even really troubleshoot effectively, which is why we provide not only an example but an example built by a script you may inspect to make sure you can reproduce actual example construction

I’m not sure what more I/we can do?

@mikehardy : Yes, similar, it shows me the same error in Android, haven’t tested with iOS

I’m getting the same issue, but running from xcode worked, when running from react-native run-ios it doesn’t instance the object properly.