React-native-device-info: NativeModule.RNDeviceInfo is NULL on RN 0.59.8 (Expo SDK 34)

Created on 5 Sep 2019  路  3Comments  路  Source: react-native-device-info/react-native-device-info

Bug

Trying to use react-native-device-info for the first time and I'm getting this error when the application tries to start up:

node_modulesreact-native\Libraries\Core\ExceptionsManager.js:74 @react-native-community/react-native-device-info: NativeModule.RNDeviceInfo is null.

Environment info

expo: 34.0.4
react: 16.8.3
react-native: 0.59.8

React native info output:

System:
    OS: Windows 10
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 21.36 GB / 31.88 GB
  Binaries:
    Node: 10.16.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.17.3 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 6.11.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.5791312
info React Native v0.60.0 is now available (your project is running on v0.59.8).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.60.0.
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.59.8.
info To upgrade, run "react-native upgrade".

Library version: 2.3.2

Steps To Reproduce

  1. Create a basic RN + Expo application
  2. Install the package by running npm install --save react-native-device-info
  3. Run react-native link react-native-device-info to create link
  4. Execute the application via expo by running expo start --android

I've also created a react-native.config.js and placed it in the root of my project:

module.exports = {
  dependency: {
    'react-native-device-info': {
      platforms: {
        android: {
          packageInstance: 'new RNDeviceInfo(false)'
        }
      }
    },
    assets: ['./assets/fonts']
  }
};

I also tried removing the folder node_modules and package-lock.json and reinstalling everything, same result.

Most helpful comment

After I posted here I continued my research and I found out that Expo and native code don't work well together. Apparently the only way to get it to work is by ejecting Expo.

Probably worth adding a note in setup guide in this regards so people using Expo don't waste time trying to get it to work.

All 3 comments

No idea. I have terrible luck troubleshooting expo things. Definitely looks like a linkage failure. You might read how to manually link and examine your files from that perspective to see if there was a link failure of some sort

After I posted here I continued my research and I found out that Expo and native code don't work well together. Apparently the only way to get it to work is by ejecting Expo.

Probably worth adding a note in setup guide in this regards so people using Expo don't waste time trying to get it to work.

Feel free to post a PR to the Troubleshooting section of the readme to dissuade people. This is widely known though - https://duckduckgo.com/?q=can+I+use+expo+with+native+modules&ia=web and well-documented https://docs.expo.io/versions/latest/introduction/why-not-expo/

Was this page helpful?
0 / 5 - 0 ratings