joltup / rn-fetch-blob

A project committed to making file access and data transfer easier, efficient for React Native developers.
MIT License
2.81k stars 770 forks source link

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

Closed fanzhiri closed 2 years ago

fanzhiri commented 4 years ago

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 https://github.com/joltup/rn-fetch-blob/issues/244#issuecomment-517205908

fanzhiri commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

chmiiller commented 4 years ago

same here

programacao5REO commented 4 years ago

Same here. :/

irajwani commented 4 years ago

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 commented 4 years ago

Any luck with this?

dca-ps commented 4 years ago

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

ckOfor commented 4 years ago

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 commented 4 years ago

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

michalgarcarz commented 4 years ago

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

abrantes01 commented 4 years ago

Facing the same problem on Android :/

davidmarinangeli commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

For android make sure to run ./gradlew clean

vkalchuk commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

pcowgill commented 4 years ago

I think this issue is a duplicate of https://github.com/joltup/rn-fetch-blob/issues/244

pcowgill commented 4 years ago

This was what fixed it for me https://github.com/joltup/rn-fetch-blob/issues/244#issuecomment-578537080

irajwani commented 4 years ago

@pcowgill yes one just had to run pod install after installing this package from npm.

pcowgill commented 4 years ago

In my case that didn’t work - it wasn’t until I deleted my Pods dir first that it worked.

TheJakey commented 4 years ago

Hi. Do we have any info about this issue? Seems like only Mac users with 'pod' are able to fix this.

TheJakey commented 4 years ago

I just found this. I'm using expo, so there is no chance to use rn-fetch-blob with expo? https://github.com/joltup/rn-fetch-blob/issues/517#issuecomment-573483891

maneesha-krishna commented 4 years ago

hey, i am facing this issue on android, can anyone help me?

maneesha-krishna commented 4 years ago

hey guys, if anyone facing this problem and already did the manual linking and still facing this problem, just delete your app from the simulator and reinstall the app. Worked for me.

alxmrtnz commented 4 years ago

Having the same issue as many of you I was trying to use this package on a React Native build for iOS and Android with redux-persist-filesystem-storage

I tried linking both automatically and manually (these instructions) to no avail. Also tried reinstalling, relinking, ./gradlew clean, ./gradlew cleanBuildCache for android and that didn't work.

I thought that it might have to do with the cycling issue (#183 ) and implemented the patch suggested here, but that didn't work.

I'm basically trying to get around AsyncStorage's 6mb limit on Android. Does anyone have alternate suggestions for redux storage options?

    "react": "16.11.0",
    "react-native": "0.62.2",
    "redux-persist-filesystem-storage": "^2.1.0",
    "redux": "^4.0.5",
    "redux-persist": "^6.0.0",
    "react-redux": "^7.1.3",
matsmello commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

pikooli commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

kykhang1997 commented 3 years ago

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

shivam-S-bisht commented 3 years ago

https://stackoverflow.com/questions/59694623/null-is-not-an-object-evaluating-rnfetchblob-documentdir-using-expo

This might help :)

guiac commented 3 years ago

any solution for Android?

cengit commented 3 years ago

manually link works for me on this issue for android:

cengit commented 3 years ago

any solution for Android?

see this : react-native-fetch-blob: https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package rn-fetch-blob: https://github.com/joltup/rn-fetch-blob/wiki/Manually-Link-Package#index

mustafakameldev commented 3 years ago

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 commented 2 years ago

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

new RNFSPackage(), new RNFetchBlobPackage()

masasidan commented 2 years ago

facing the same issue. no solution yet?

zabojad commented 2 years ago

Same here, RN 0.66 on Android :(

zabojad commented 2 years ago

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

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