Skip to content
This repository has been archived by the owner on Mar 16, 2019. It is now read-only.

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

Open
apatton724 opened this issue May 25, 2017 · 30 comments

Comments

@apatton724
Copy link

apatton724 commented May 25, 2017

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
Copy link
Author

"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"
},

@Jacse
Copy link
Contributor

Jacse commented Jun 3, 2017

I think you have to use RNFetchBlob.dirs.DocumentDir

@Antoine-Mace
Copy link

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

@apatton724
Copy link
Author

Thanks for the response @Jacse .

How and where would I use that at?

@Antoine-Mace
Copy link

Antoine-Mace commented Jun 5, 2017

@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.

@apatton724
Copy link
Author

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

@poptocrack
Copy link

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

@lf-alves
Copy link

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

@FiddlyDigital
Copy link

Same issue here but not using Expo

@flieks
Copy link

flieks commented Aug 29, 2017

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

@bispul
Copy link

bispul commented Oct 4, 2017

did anyone got the solution ?

@jbaek7023
Copy link

Same issue here :(

@flieks
Copy link

flieks commented Nov 7, 2017

probably need to wait until this is merged: facebook/react-native#11573

@yingbang
Copy link

qq 20171210093844

@fubar
Copy link

fubar commented Dec 21, 2017

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

@Ciberusps
Copy link

same issue (

@eduardoboca
Copy link

Same issue here. Has anybody found the solution?

@jdeibe
Copy link

jdeibe commented Feb 19, 2018

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

@eduardoboca
Copy link

@jdeibe, are you using Expo as well?

@jdeibe
Copy link

jdeibe commented Feb 20, 2018 via email

@eduardoboca
Copy link

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

@eddyjusufi
Copy link

eddyjusufi commented Feb 27, 2018

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.

@hjbramos
Copy link

hjbramos commented Mar 7, 2018

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!

@gunzino
Copy link

gunzino commented Mar 12, 2018

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

@yingdongzhang
Copy link

yingdongzhang commented Mar 27, 2018

@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

@JulianKingman
Copy link

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.

@MojtabaRezaeimehr
Copy link

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

@jettandres
Copy link

jettandres commented Aug 4, 2018

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

@arturo181991
Copy link

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

@tiyunchen
Copy link

same error

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

No branches or pull requests