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

undefined is not an object (evaluating 'RNFetchBlob.DocumentDir') #84

Closed
ramigamalrihawi opened this issue Aug 14, 2016 · 45 comments
Closed

Comments

@ramigamalrihawi
Copy link

ramigamalrihawi commented Aug 14, 2016

hey guy i'm getting this error undefined is not an object (evaluating 'RNFetchBlob.DocumentDir') ..
i know this was mentioned before but all the solutions didn't help fix the problem for me
i'm going crazy .. i've been trying 9 hours to fix it with no luck
i tried rnpm and didn't work then tried linking manually and still didn't work
i'm using linux and android
and this is my package file

  "name": "funshare",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start"
  },
  "dependencies": {
    "base-64": "^0.1.0",
    "firebase": "^3.1.0",
    "react": "15.2.1",
    "react-native": "0.29.1",
    "react-native-cli": "^1.0.0",
    "react-native-fbsdk": "^0.2.2",
    "react-native-fbsdkcore": "0.0.8",
    "react-native-fbsdklogin": "0.0.8",
    "react-native-fbsdkshare": "0.0.8",
    "react-native-fetch-blob": "^0.6.4",
    "react-native-gifted-spinner": "0.0.5",
    "react-native-icon-badge": "^1.1.1",
    "react-native-image-picker": "^0.21.1",
    "react-native-swipe-cards": "0.0.7",
    "react-native-swiper": "^1.4.8",
    "reflux": "^0.4.1"
  }
}
@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

Hi @rameramwe , apparently you're getting this error because the library is not linked properly. I've noticed that you might using an very old version of this library (0.6.4). Perhaps you can try the following steps :

First, close the app and packager.

Then upgrade rnpm

$ npm install -g rnpm

Remove the installed package

$ rnpm uninstall react-native-fetch-blob

Re-install the library

$ npm install --save react-native-fetch-blob && rnpm link

And there should be some logs in the terminal

2016-08-14 12 25 45

To verify if the library is linked properly, check if these lines exists in settings.gradle

include ':react-native-fetch-blob'
project(':react-native-fetch-blob').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-fetch-blob/android')

Also check MainApplication.java

import com.RNFetchBlob.RNFetchBlobPackage;
@Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
+          new RNFetchBlobPackage(),                                                                                                                             
         new MainReactPackage()
      );
    }

Now, run the app see if it work properly

$ react-native run-android

React Native has changed its Android application template in 0.29 which result in rnpm link not working with RN 0.29.0, and 0.29.1. However we've fixed this problem by adding custom rnpm.

@RichardBoyewa
Copy link

@wkh237 Thanks. Let me try that now.

@RichardBoyewa
Copy link

@wkh237 I am still getting the same. Could it be because I am using it from a worker? It is used alongside with react-native-workers could that be the problem; I doubt it.

Thanks

@RichardBoyewa
Copy link

image

Thats what I got after running rnpm link

@ramigamalrihawi
Copy link
Author

hey @wkh237 thanks a lot for the fast and awesome response
i did exactly like you said and i even got the same results in my terminal but still the same error :(
screenshot from 2016-08-14 07 23 36

then i tried deleting the build folder in my android folder and uninstalling the package and then reinstalling it and compiling but still no luck ..

@ramigamalrihawi
Copy link
Author

@RichardBoyewa hey man about the skipped thing i got it too you gotta delete this line new RNFetchBlobPackage(), in mainapplication.java and it'll work actually it'll just add it again :P .

@ramigamalrihawi
Copy link
Author

@wkh237 i noticed this while compiling ..does it matter ?
screenshot from 2016-08-14 07 34 46

@RichardBoyewa
Copy link

@rameramwe I did just that and the error is still there. Are you using it from a worker service? I am using this for a background service.
Worker : react-native-workers

@ramigamalrihawi
Copy link
Author

@RichardBoyewa actually no i'm not using Workers but i'm using other stuff like image picker and Fbsdk do you think this might be causing the problem ?

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

@RichardBoyewa , if you're using react-native-workers did you add

new WorkerPackage(new MyAwesomePackage(), new MyAmazingPackage())

to WorkerPackage constructor (which should located in node_modules/react-native-workers/android/src/main/java/co/apptailor/Worker/WorkerPackage.java line 34) ?

@RichardBoyewa
Copy link

I am not sure. I have been on this for a while... But this is an interesting package, I will fight my way through it :-)

@RichardBoyewa
Copy link

@wkh237 Let me do that.... I missed that line :-(

@ramigamalrihawi
Copy link
Author

this package is essential for me cause i'm using firebase and i need firebase storage .

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

@rameramwe , does the firebase upload sample work on you environment ?

@ramigamalrihawi
Copy link
Author

i'll check that and see

@RichardBoyewa
Copy link

Heyyyyyyyyyyyyy! 👍 It works.......... uuuuhhnnnnnnn!!! Dancing..... @rameramwe How far with yours? @wkh237 Thanks a billion. Can we drop this line as a comment in the ReadMe, incase someone else try to use it this way.

Thanks guys. You rock!

@ramigamalrihawi
Copy link
Author

@RichardBoyewa congrats man :D hope i can fix it too :P

@RichardBoyewa
Copy link

@rameramwe How can I message you directly... there is something you need to take out of your repo ASAP.... Don't commit that to gitHub

@RichardBoyewa
Copy link

@rameramwe check your dependencies to see that they don't need a special installation like mine.

@RichardBoyewa
Copy link

:-) Sent you a mail. Have u solved urs ?

@ramigamalrihawi
Copy link
Author

no not yet i'm trying to get the firebase upload repo running locally and see what'S going on

@RichardBoyewa
Copy link

ok. Best of luck.

@ramigamalrihawi
Copy link
Author

ramigamalrihawi commented Aug 14, 2016

@wkh237 i got the repo running and it works and it gave me 80% result why the hell ain't it working with original app ? that'S the package file for the upload repo
{
"name": "RNFirebaseUploadSample",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start"
},
"dependencies": {
"firebase": "^3.2.0",
"react": "15.2.1",
"react-native": "^0.28.0",
"react-native-fetch-blob": "0.9.1",
"react-native-testkit": "^0.1.1",
"react-timer-mixin": "^0.13.3"
}
}
you can see here i'm using react native v0.28.0

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

@rameramwe , I've tested the library with 0.29.1 Ubuntu 15 environment and it works fine. Could you provide a simplified sample of your project ?

@ramigamalrihawi
Copy link
Author

@wkh237 would you like to see the repo ? it's not that big
thank you very much for the help

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

Yeah, I'd like to help if it's possible.

@ramigamalrihawi
Copy link
Author

@wkh237 Awesome :D that'S the repo https://github.com/rameramwe/funshare

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

2016-08-14 3 45 36

@rameramwe , when I try to run the application but it gives me a totally different error message saying that something is incorrect in `SwipeCard.js`.

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

I temporarily removed anything in index.android.js it works now.
2016-08-14 3 48 41

@ramigamalrihawi
Copy link
Author

ramigamalrihawi commented Aug 14, 2016

@wkh237 great .. it'S not important anyways but you should require the library fetch blob and see if it works

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

@rameramwe , I've noticed that FacebookSDK uses different Android Build Tool (23.0.2) and React Native uses 23.0.1. When the first time I try to build the project, it shows the following error message.

issue1

I'm wondering if your environment missed this build tool too. I fix this error by simply open the Android project with Android Studio and install the build tool. Have you tried build the project using Android Studio ?

There's also a StackOverflow thread about install build tools using command line.

@ramigamalrihawi
Copy link
Author

@wkh237 no i didn't use android studio

@ramigamalrihawi
Copy link
Author

i never got this error

@wkh237
Copy link
Owner

wkh237 commented Aug 14, 2016

After upgrade react-native-swipe-cards to 0.8.0 and fix the missing comma in SwipeCards.js the app work properly now. Perhaps try clone the repo and reinstall the npm packages ?

runnung

@ramigamalrihawi
Copy link
Author

@wkh237 thank you very much i go it to work .. i was testing not on genymotion but on my phone .. the solution was to uninstall the app from my phone and reinstalling it using run-android .. that'S very weird but now it's working perfectly thank you very much again .

@wkh237
Copy link
Owner

wkh237 commented Aug 15, 2016

@rameramwe , great to hear that ! Please feel free ask any question when needed 😄

@RichardBoyewa
Copy link

Nice job done here @wkh237 . @rameramwe Glad you finally got it to work.

@zxx714
Copy link

zxx714 commented Oct 25, 2016

I'll get this exception if I turn on the "Don't keep activities" setting in android. If I turn it off, I can use this library normally. My version is
"react-native-fetch-blob": "^0.9.6".

Thanks.

@dwilt
Copy link

dwilt commented Dec 6, 2016

I am trying to install your plugin and having this problem. I've tried starting from scratch twice in the past week and I keep getting this screen. I got it installed after a while the first time but I had to reinstall again can't remember how I got around it.

First off, a couple comments about your installation instructions:

  1. You first mention to install the package with npm via npm install --save react-native-fetch-blob. That's fine. However, right after that you say:

Or if using CocoaPods, add the pod to your Podfile, for example:

If I'm correct, it's not an "or" but a required 2nd step. By using CocoPods, you get the required iOS files right? Also, there should be a pod install instruction after adding the line to the Podfile right? However, when I run pod install, it hangs on trying to install React (0.11.0):

image

@dwilt
Copy link

dwilt commented Dec 6, 2016

pod install finally finished but it says React has been deprecated:
image
And I'm seeing this when trying to run react-native run-ios now:



** BUILD FAILED **


The following build commands failed:
        CompileC /Users/dwilt/Projects/GJS/gjs-app/ios/build/Build/Intermediates/Pods.build/Release-iphonesimulator/react-native-fetch-blob.build/Objects-normal/i386/RNFetchBlob.o /Users/dwilt/Projects/GJS/gjs-app/node_modules/react-native-fetch-blob/ios/RNFetchBlob/RNFetchBlob.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
        CompileC /Users/dwilt/Projects/GJS/gjs-app/ios/build/Build/Intermediates/Pods.build/Release-iphonesimulator/react-native-fetch-blob.build/Objects-normal/i386/RNFetchBlobFS.o /Users/dwilt/Projects/GJS/gjs-app/node_modules/react-native-fetch-blob/ios/RNFetchBlobFS.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

@naviocean
Copy link

I got a same issue of @dwilt

@slender9168
Copy link

Two things solved the problem for me:
1- use the react-native link command
2- deploy the app again to the device from android studio ( i think using the package manager (npm start) only packages the new javascript code, not the library native code )

@jeremyha1106
Copy link

I'm getting the same issue but i'm using expo. How can i fix it without detach the project, please help!!

@harish-aka-shivi
Copy link

If you are making a Activity and implementing DefaultHardwareBackBtnHandler, then in your onCreate(Bundle savedInstanceState), use addPackage() method like this:

mReactInstanceManager = ReactInstanceManager.builder() .setApplication(getApplication()) .setBundleAssetName("index.android.bundle") .setJSMainModulePath("index.android") .addPackage(new MainReactPackage()) .addPackage(new RNFetchBlobPackage()) .setUseDeveloperSupport(BuildConfig.DEBUG) .setInitialLifecycleState(LifecycleState.RESUMED) .build();

@krishan-kumar-mourya
Copy link

After linking you need to run
pod update

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

10 participants