react-native-fetch-blob icon indicating copy to clipboard operation
react-native-fetch-blob copied to clipboard

EXPO + Android 7.0 - undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')

Open apatton724 opened this issue 8 years ago • 30 comments

Hi there,

I know this has been an issue in the past. However, I am using Expo to upload files using the react-native-fetch-blob.

Can someone walk me through how to avoid this issue in android 7.0? In the README it says I have to have the permission granted: https://github.com/wkh237/react-native-fetch-blob#installation

"Beginning in Android 6.0 (API level 23), users grant permissions to apps while the app is running, not when they install the app. So adding permissions in AndroidManifest.xml won't work for Android 6.0+ devices. To grant permissions in runtime, you might use PermissionAndroid API."

As I stated, I'm using Expo. Before I get to the point of asking the user for permission...on load of the app, I get the above mentioned error.

Any ideas on how to reconcile this?

apatton724 avatar May 25 '17 03:05 apatton724

"dependencies": { "@expo/ex-navigation": "~2.10.0", "@expo/samples": "~1.0.3", "expo": "16.0.0", "react": "16.0.0-alpha.6", "react-native": "https://github.com/expo/react-native/archive/sdk-16.0.0.tar.gz", "react-native-datepicker": "^1.5.1", "react-native-fetch-blob": "^0.10.5", "redux": "^3.6.0" },

apatton724 avatar May 25 '17 04:05 apatton724

I think you have to use RNFetchBlob.dirs.DocumentDir

Jacse avatar Jun 03 '17 17:06 Jacse

UP, I encountered the same error today

dependencies : "react": "16.0.0-alpha.6", "react-native": "0.44.0", "react-native-fetch-blob": "0.10.5"

@Jacse In my case I do use RNFetchBlob.fs.dirs.DocumentDir

If anyone as any fix, solution it will be awesome

thanks

screen shot 2017-06-05 at 14 30 03

Antoine-Mace avatar Jun 05 '17 13:06 Antoine-Mace

Thanks for the response @Jacse .

How and where would I use that at?

apatton724 avatar Jun 05 '17 13:06 apatton724

@apatton724 I solved my issue by simply running npm install --save react-native-fetch-blob

Just in case before running the install you can watchman watch-del-all && npm cache clean to start from fresh and using after npm start -- --reset-cache to lunch the packager, hope it will resolve your issue.

to answer your question, DocumentDir is just a path which is created dynamically by the RNfetchBlob.fs API depending on your Platform, you don't necessarily have to use it it's just a useful constant.

Antoine-Mace avatar Jun 05 '17 14:06 Antoine-Mace

Thank you @Antoine-Mace , I will give this a go!

apatton724 avatar Jun 23 '17 12:06 apatton724

@apatton724 Do you still have the issue? Because I still have it

poptocrack avatar Jul 11 '17 16:07 poptocrack

I'm having the same issue (also using Expo)

lf-alves avatar Jul 18 '17 05:07 lf-alves

Same issue here but not using Expo

FiddlyDigital avatar Jul 30 '17 16:07 FiddlyDigital

@lf-alves @poptocrack @apatton724 any luck with expo ? I need to open/view and upload a local pdf file so i need this.

flieks avatar Aug 29 '17 15:08 flieks

did anyone got the solution ?

bispul avatar Oct 04 '17 18:10 bispul

Same issue here :(

jbaek7023 avatar Nov 03 '17 05:11 jbaek7023

probably need to wait until this is merged: https://github.com/facebook/react-native/pull/11573

flieks avatar Nov 07 '17 09:11 flieks

qq 20171210093844

yingbang avatar Dec 10 '17 01:12 yingbang

For those who ran into this issue, make sure to recompile your app after running the react-native link command.

fubar avatar Dec 21 '17 21:12 fubar

same issue (

Ciberusps avatar Jan 04 '18 06:01 Ciberusps

Same issue here. Has anybody found the solution?

eduardoboca avatar Feb 19 '18 01:02 eduardoboca

I also got the undefined is not an object (evaluating 'RNFetchBlob.DocumentDir') and entering manual installation fixed the issue. https://github.com/wkh237/react-native-fetch-blob/wiki/Manually-Link-Package#link-android-package

jdeibe avatar Feb 19 '18 08:02 jdeibe

@jdeibe, are you using Expo as well?

eduardoboca avatar Feb 19 '18 14:02 eduardoboca

Nope.

jdeibe avatar Feb 20 '18 08:02 jdeibe

@wkh237, do you have any info on this? I mean, does it work with Expo?

eduardoboca avatar Feb 20 '18 12:02 eduardoboca

Has anyone managed to fix the error (undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')) for Expo? Most of the solutions above are when the app is actually detaching from Expo but not solutions for running it on Expo specifically.

eddyjusufi avatar Feb 27 '18 02:02 eddyjusufi

Create an environment variable on you OS 'RNFB_ANDROID_PERMISSIONS' and set it to 'true'. Then run 'react-native link react-native-fetch-blob' again. Works for me!

hjbramos avatar Mar 07 '18 06:03 hjbramos

I think this package is not compatible with Expo because you cannot use additional native code in expo packages

gunzino avatar Mar 12 '18 07:03 gunzino

@EddieEJ It doesn't work with Expo because Expo doesn't support native module linking. Like you said you'll have to detach from Expo in order to run react-native link react-native-fetch-blob for this to work. https://docs.expo.io/versions/latest/guides/detach.html

yingdongzhang avatar Mar 27 '18 06:03 yingdongzhang

With a detached Expo project, you have to first run react-native link, then (in the /ios directory) run pod install. You may also have to fix headers, for which I recommend the react-native-fix-headers package.

JulianKingman avatar May 28 '18 14:05 JulianKingman

Same issue, it made me frustrated! I'm testing it on android but it doesn't work!!!!! Heeeeeeelp please...

MojtabaRezaeimehr avatar Jul 26 '18 11:07 MojtabaRezaeimehr

I've tested this out and it turned out the location object being returned by Location.getCurrentPositionAsync() has a coords property that you'll use to access both longitude and latitude. So it should be location.coords.latitude or location.coords.longitude instead of what's been officially documented

More info here https://forums.expo.io/t/location-is-not-working/1004/4

jettandres avatar Aug 04 '18 06:08 jettandres

I have the same issue on Expo and I trying to compile for Android and my app shows me "RNFetchBlob.DocumentDir", after to run react-native link system says "rn-fetch-blob will not automatically add Android permissions after 0.9.4 please run the following command if you want to add default permissions: RNFB_ANDROID_PERMISSIONS=true react-native link", but then shows me "RNFetchBlob checking app version .. RNFetchBlob detected app version => 1 Add Android permissions => false" . Did someone find the solution? thanks

My OS: Debian 9 react-native: 0.57.1

arturo181991 avatar Dec 14 '18 21:12 arturo181991

same error

tiyunchen avatar Dec 24 '18 07:12 tiyunchen