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.
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
npm install --save react-native-device-inforeact-native link react-native-device-info to create linkexpo start --androidI'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.
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/
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.