2

I have been trying to use "React-Native-FS" while developing a react native application. However, whenever I try to import "React-Native-FS" to my app I get the following message:

Invariant Violation: Native Module Cannot Be Null

Does anyone have any clue what could be causing this? I've searched around and can't find an answer. Any help would be greatly appreciated. Thanks!

1 Answers1

0

try to do link your library with

react-native link react-native-fs

if its not linked try to do manually linking with below step

ANDROID

... 1. android/settings.gradle
 include ':react-native-fs'
 project(':react-native-fs').projectDir = new File(settingsDir,'../node_modules/react-native-fs/android')

 2.android/app/build.gradle
 dependencies {
 implementation project(':react-native-fs')  
}

ANd do build android project with android studio

IOS

Adding with CocoaPods Add the RNFS pod to your list of application pods in your Podfile, using the path from the Podfile to the installed module:~~

pod 'RNFS', :path => '../node_modules/react-native-fs' Install pods as usual:

pod install Adding Manually in XCode In XCode, in the project navigator, right click Libraries ➜ Add Files to [your project's name] Go to node_modules ➜ react-native-fs and add the .xcodeproj file

In XCode, in the project navigator, select your project. Add the lib*.a from the RNFS project to your project's Build Phases ➜ Link Binary With Libraries. Click the .xcodeproj file you added before in the project navigator and go the Build Settings tab. Make sure 'All' is toggled on (instead of 'Basic'). Look for Header Search Paths and make sure it contains both $(SRCROOT)/../react-native/React and $(SRCROOT)/../../React - mark both as recursive.

Run your project (Cmd+R)

Mayank Pandav
  • 359
  • 4
  • 19
  • Thanks for the response! I've tried linking it with your first suggestion already, and sadly that didn't work. As for the other two suggestions I am using a combination of IntelliJ IDEA and Expo to develop my app. Any suggestions for how to get it running this way? EDIT: With a little further research I've discovered that Expo doesn't seem to support React Native FS... I guess if this is true I should probably try one of the other solutions... – AirtightSpring Feb 05 '20 at 23:37
  • Yes expo don't have support you have to eject current expo project to move on react native project – Mayank Pandav Feb 06 '20 at 03:15