Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

null is not an object (evaluating 'RNFetchBlob.DocumentDir') #422

Closed
fanzhiri opened this issue Aug 16, 2019 · 63 comments
Closed

null is not an object (evaluating 'RNFetchBlob.DocumentDir') #422

fanzhiri opened this issue Aug 16, 2019 · 63 comments

Comments

@fanzhiri
Copy link

We're having a similar issue after upgrading to React Native 0.60 and using auto linking.

Screenshot_20190801-112619_Yeppik

Originally posted by @EgidioCaprino in #244 (comment)

@fanzhiri
Copy link
Author

I add pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' to the ios/Podfile , and run the cmd pod install , then the issue does not appear

@gongmingqm10
Copy link

image

I encountered the same problem. And the version I am using is 0.10.15. And I figured out how to fix it.

You should manually add the libRNFetchBlob.a to your target's linked frameworks and libraries. Follow the step Click the targets > General > Linked Frameworks and Libraries > Click + > Click libRNFetchBlob.a.

After that, clean your iOS build and rerun your App. Then everything will back to normal.

@irajwani
Copy link

irajwani commented Oct 8, 2019

Hi @gongmingqm10 the reason I cannot add libRNFetchBlob.a with my project is that react native 0.60.+ "installs" your 3rd party libraries through the Pods method and now we do not have to add those libraries under our .xcodeproj and then add .a files under Link binary with libraries. Are you also using RN 0.60.+ ??

@irajwani
Copy link

irajwani commented Oct 8, 2019

I add pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' to the ios/Podfile , and run the cmd pod install , then the issue does not appear

This did not work for me.

@fgagneten
Copy link

Same issue here. I got this error after replacing manually link to auto-linking. Any solution for that?

@chmiiller
Copy link

same here

@programacao5REO
Copy link

Same here. :/

@irajwani
Copy link

irajwani commented Oct 18, 2019

I think I've beaten this error (not sure because now my app builds and now that I'm in JS world I'm getting errors for linking issues with another library: react-native-push-notification). I think that this library's installation is being handled through Pods but I've also manually linked it by adding RNFetchBlob.xcodeproj under Libraries and I've also placed librn-fetch-blob.a under link binary with libraries. This is my Podfile:

platform :ios, '9.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'iosNottMyStyle' do

Pods for iosNottMyStyle

pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/React'
pod 'React-DevSupport', :path => '../node_modules/react-native/React'
#pod 'React-fishhook', :path => '../node_modules/react-native/Libraries/fishhook'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-RCTWebSocket', :path => '../node_modules/react-native/Libraries/WebSocket'
pod 'React-RCTPushNotification', :path => '../node_modules/react-native/Libraries/PushNotificationIOS'

pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'yoga', :path => '../node_modules/react-native/ReactCommon/yoga'

pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'

pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

target 'iosNottMyStyleTests' do
inherit! :search_paths
# Pods for testing
end

use_native_modules!
end

target 'iosNottMyStyle-tvOS' do

Pods for iosNottMyStyle-tvOS

target 'iosNottMyStyle-tvOSTests' do
inherit! :search_paths
# Pods for testing
end

end

@ckOfor
Copy link

ckOfor commented Oct 20, 2019

Any luck with this?

@dca-ps
Copy link

dca-ps commented Oct 22, 2019

Having the same error here in android with RN 0.61.1 using autolink

@ckOfor
Copy link

ckOfor commented Oct 23, 2019

To solve this @dca-ps

  1. First add pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' to podfile
  2. run yarn add rn-fetch-blob

@mauricioblum
Copy link

Same issue here, and @ckOfor solution did not work.

@michalgarcarz
Copy link

michalgarcarz commented Oct 27, 2019

the same here, still hitting this bug and can not find the workaround (none of above working).

@abrantes01
Copy link

Facing the same problem on Android :/

@davidmarinangeli
Copy link

Hi guys: the only fix I have found for this issue is to use the good old manual linking.

In MainApplication.java add:

...
import com.RNFetchBlob.RNFetchBlobPackage;
...



    protected List<ReactPackage> getPackages() {
        // Add additional packages you require here
        // No need to add RnnPackage and MainReactPackage
        return Arrays.<ReactPackage>asList(
                 ...
                new RNFetchBlobPackage(), <- add this
        );
    }

@abrantes01
Copy link

Ok, looks like it was related with 0.60 autolinking feature for me. Unlike @davidmarinangeli , I had to remove the packages import from my MainApplication.java. If you've just updated from react-native < 0.60, make sure that you've correctly enabled autolinking with this (in android/settings.graddle) :

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

Here is the upgrade helper : https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.61.2

@davidmarinangeli
Copy link

Ok, looks like it was related with 0.60 autolinking feature for me. Unlike @davidmarinangeli , I had to remove the packages import from my MainApplication.java. If you've just updated from react-native < 0.60, make sure that you've correctly enabled autolinking with this (in android/settings.graddle) :

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

Here is the upgrade helper : https://react-native-community.github.io/upgrade-helper/?from=0.59.9&to=0.61.2

I had this line at the bottom of my settings.gradle file but it did not work 😢 . The helper has been useful indeed.

@jrartiga
Copy link

jrartiga commented Nov 5, 2019

Hi guys: the only fix I have found for this issue is to use the good old manual linking.

In MainApplication.java add:

...
import com.RNFetchBlob.RNFetchBlobPackage;
...



    protected List<ReactPackage> getPackages() {
        // Add additional packages you require here
        // No need to add RnnPackage and MainReactPackage
        return Arrays.<ReactPackage>asList(
                 ...
                new RNFetchBlobPackage(), <- add this
        );
    }

I have tried this one, but no luck at all, I got the same, I got pretty much the same issue
console.log(About to save ${url_video} into cameraRoll...`);

RNFetchBlob
.config({
    fileCache : true,
    appendExt : 'mp4'
})
.fetch('GET',url_video)
    .then((res) => {
        CameraRoll.saveToCameraRoll(res.path())
            .then(()=>console.log("stored successfully"))
            .catch(err => console.warn(err))
    })`

image

@tronxdev
Copy link

tronxdev commented Nov 14, 2019

Hi guys,

Recently I upgraded a RN app from v0.59.9 to v0.61.4. It had the same issue:

TypeError: null is not an object (evaluating 'RNFetchBlob.DocumentDir')

Here is my solution to the issue fix.

Add pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' to Podfile.
Run yarn add rn-fetch-blob && cd ios && pod install && cd .. && npx react-native run-ios

@Atuldhaka
Copy link

Hi guys i was facing the same issue resolved it by : -

  1. killall node.
  2. uninstall your application from your simulator or device.
  3. npm install
  4. npm start.
  5. react-native run-ios (i.e. install and run again).

@wilau2
Copy link

wilau2 commented Nov 28, 2019

For android make sure to run ./gradlew clean

@vkalchuk
Copy link

I'm having this issue on Android 9.0+
Reinstalling, relinking, ./gradlew clean, ./gradlew cleanBuildCache does not help.

Works fine on Android 8.1 though

@karan-chaudhari
Copy link

Hi guys: the only fix I have found for this issue is to use the good old manual linking.
In MainApplication.java add:

...
import com.RNFetchBlob.RNFetchBlobPackage;
...



    protected List<ReactPackage> getPackages() {
        // Add additional packages you require here
        // No need to add RnnPackage and MainReactPackage
        return Arrays.<ReactPackage>asList(
                 ...
                new RNFetchBlobPackage(), <- add this
        );
    }

I have tried this one, but no luck at all, I got the same, I got pretty much the same issue
console.log(About to save ${url_video} into cameraRoll...`);

RNFetchBlob
.config({
    fileCache : true,
    appendExt : 'mp4'
})
.fetch('GET',url_video)
    .then((res) => {
        CameraRoll.saveToCameraRoll(res.path())
            .then(()=>console.log("stored successfully"))
            .catch(err => console.warn(err))
    })`

image

Did you fix this error??

@redstubble
Copy link

Was facing same issue for Android was related to MainApplication.java not being updated as part of upgrade from 0.59 - 0.60 as outlined by @abrantes01

@vijeshvenugopalan
Copy link

I missed this step "react-native link rn-fetch-blob" and it was creating "null is not an object" error

@pcowgill
Copy link

I think this issue is a duplicate of #244

@pcowgill
Copy link

pcowgill commented Jan 26, 2020

This was what fixed it for me #244 (comment)

@matsmello
Copy link

matsmello commented Jun 21, 2020

I had that problem, so How I solved it ?
"react": "16.9.0", "react-native": "0.61.5", "rn-fetch-blob": "^0.12.0"

All commands bellow started at root folder
I installed the packed using yarn add rn-fetch-blob
Then I used react-native link rn-fetch-blob
After those commands I used RNFB_ANDROID_PERMISSIONS=true react-native link rn-fetch-blob
So, I go to ios folder using cd ios then I installed pod using pod install
After those moves I opened my project.xcodeproj goes to
image
On general tab and added librn-fetch-blob.a using the plus signal
After that I closed my node server and iOS simulator, and click on Build at Xcode and it worked.

I hope it helped you too. ✌🏻👌🏻

@diogomachado
Copy link

image

I encountered the same problem. And the version I am using is 0.10.15. And I figured out how to fix it.

You should manually add the libRNFetchBlob.a to your target's linked frameworks and libraries. Follow the step Click the targets > General > Linked Frameworks and Libraries > Click + > Click libRNFetchBlob.a.

After that, clean your iOS build and rerun your App. Then everything will back to normal.

I need before install pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' and after Link de Lib using Xcode, and works!

@mathanpec
Copy link

@alxmrtnz, Add rn-fetch-blog v0.12.0 as dependency to your project itself and it should work

@pikooli
Copy link

pikooli commented Jul 28, 2020

did someone fixe this issue ? it just when you import this with expo.
if you do it without expo it look like it work, use this in a project make with npx react-native, it work fine but not expo :/

@gzimh
Copy link

gzimh commented Sep 9, 2020

Hi guys,

Recently I upgraded a RN app from v0.59.9 to v0.61.4. It had the same issue:

TypeError: null is not an object (evaluating 'RNFetchBlob.DocumentDir')

Here is my solution to the issue fix.

Add pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob' to Podfile.
Run yarn add rn-fetch-blob && cd ios && pod install && cd .. && npx react-native run-ios

pod install did it for me, thanks 🥂

@DastoBuniq
Copy link

just go in node_modules->rn-fetch-blob->fs.js uncomment line 5 or replace line 13 with 'const RNFetchBlob = NativeModules.RNFetchBlob'

@kykhang1997
Copy link

I am also having the same problem. but only suffer on android, ios it runs normally, please help me

@guiac
Copy link

guiac commented Jan 28, 2021

any solution for Android?

@cengit
Copy link

cengit commented Mar 22, 2021

manually link works for me on this issue for android:

@cengit
Copy link

cengit commented Mar 22, 2021

@mustafakameldev
Copy link

in node_modules/rn-fetch-blob/android/build.gradle
i added :
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
it works with me source : https://github.com/joltup/rn-fetch-blob/wiki/Manually-Link-Package#index

@rajeevrocker7
Copy link

in Android->MainApplication.java add these 2 if you are using both after linking..
check if not present, add both:

new RNFSPackage(), new RNFetchBlobPackage()

@fanzhiri fanzhiri closed this as completed Sep 8, 2021
@masasidan
Copy link

facing the same issue. no solution yet?

@zabojad
Copy link

zabojad commented Jan 10, 2022

Same here, RN 0.66 on Android :(

@zabojad
Copy link

zabojad commented Jan 10, 2022

After a second thought, it's not the same issue on RN 0.66 :

TypeError: null is not an object (evaluating 'ReactNativeBlobUtil.DocumentDir')

@zabojad
Copy link

zabojad commented Jan 10, 2022

@MarquisAlexander
Copy link

this happened to me on android, i run a react-native run-android and the problem stopped happening

@trandinhhiep789
Copy link

and now it's stuck in ios versions, any solution for Ios?

@stoplion
Copy link

stoplion commented Jun 1, 2022

Stuck on the same problem.

@fukemy
Copy link

fukemy commented Jun 14, 2022

pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

then i got this error:

error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: 
  - rn-fetch-blob (to unlink run: "react-native unlink rn-fetch-blob")
  - ....

Then npm run ios throw error with 100000000+ lines of info

@INnoVatioN-97
Copy link

Hi guys: the only fix I have found for this issue is to use the good old manual linking.

In MainApplication.java add:

...
import com.RNFetchBlob.RNFetchBlobPackage;
...



    protected List<ReactPackage> getPackages() {
        // Add additional packages you require here
        // No need to add RnnPackage and MainReactPackage
        return Arrays.<ReactPackage>asList(
                 ...
                new RNFetchBlobPackage(), <- add this
        );
    }

I think It doesn't work for me...
is here anybody solved this problem??

@hariskhalid366
Copy link

i have the same issue in android can you explain it for android

@hariskhalid366
Copy link

ERROR TypeError: Cannot read property 'DocumentDir' of null, js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes
ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient.
A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

im facing this in android

@polsust
Copy link

polsust commented Dec 12, 2022

ERROR TypeError: Cannot read property 'DocumentDir' of null, js engine: hermes ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes

im facing this in android

I'm getting this same error, only on real hardware (not on an emulator)

@hariskhalid366
Copy link

hariskhalid366 commented Dec 12, 2022 via email

@polsust
Copy link

polsust commented Dec 12, 2022

B

First delete the node_module folder rm -rf node_module/ then npm install After that go to androd folder and ./gradlew clean then npx react-native run-android

On Mon, Dec 12, 2022, 7:02 PM Pol Sust @.> wrote: ERROR TypeError: Cannot read property 'DocumentDir' of null, js engine: hermes ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes ERROR Invariant Violation: Failed to call into JavaScript module method AppRegistry.runApplication(). Module has not been registered as callable. Registered callable JavaScript modules (n = 10): Systrace, JSTimers, HeapCapture, SamplingProfiler, RCTLog, RCTDeviceEventEmitter, RCTNativeAppEventEmitter, GlobalPerformanceLogger, JSDevSupportModule, HMRClient. A frequent cause of the error is that the application entry file path is incorrect. This can also happen when the JS bundle is corrupt or there is an early initialization error when loading React Native., js engine: hermes im facing this in android I'm getting this same error, only on real hardware (not on an emulator) — Reply to this email directly, view it on GitHub <#422 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT25EBFH4KOUYQHYM56KJKTWM4V53ANCNFSM4IMFXPJQ . You are receiving this because you commented.Message ID: @.>

But It already worked on the emulator, however it's still not working on real hardware

@hariskhalid366
Copy link

hariskhalid366 commented Dec 13, 2022 via email

@vikram-segta
Copy link

I also have same issue after 'npm install rn-fetch-blob --save' in android
react-native - 0.64.3 --version

1.) cd android
Navigate to android directory from the root directory of your React Native project.

2.) ./gradlew clean
This command will delete all the temporary files and build artifacts generated during the previous build

3.) ./gradlew assembleDebug
This command will build your application and generate the APK file that you can use to install on your Android device

This is work for me 😃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests