参考https://github.com/wkh237/react-native-fetch-blob/issues/51 自己做了一下总结:

这个报错位置在react-native-fetch-blob下fs.js:

DocumentDir :  RNFetchBlob.DocumentDir 

首先看一下最外层package.json下是否有“react-native-fetch-blob”该依赖包

如果没有

就执行下面命令行:

$ npm install --save react-native-fetch-blob@0.10.5

如果react-native-fetch-blob版本较低,移除原有包
$ rnpm uninstall react-native-fetch-blob
重新按上面安装
react-native版本< 0.29 
$ rnpm link
react-native版本 0.29.2+
$ react-native link

执行$ rnpm link或rnpm uninstall时可能提示:

参考 https://github.com/rnpm/rnpm 执行命令行:

$ npm install rnpm -g

再执行$ rnpm link或rnpm uninstall

如果出现以下提示:

可参考react-native-fetch-blob\README.md文件:

react-native版本< 0.29

$ RNFB_ANDROID_PERMISSIONS=true rnpm link

react-native版本 0.29.2+
$ RNFB_ANDROID_PERMISSIONS=true react-native link
自动添加权限(亲测RNFB_ANDROID_PERMISSIONS不是内部或外部命令,未解决)。或者用以下手动添加:

对于5.0及以下的设备,你必须手动添加以下权限:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
对Android 6.0 (API level 23),请求权限参照
https://facebook.github.io/react-native/docs/permissionsandroid.html

如果使用`Android Download Manager`需添加

<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.DOWNLOAD_COMPLETE"/>
</intent-filter>

连接成功后,在terminal会出现下面提示

在settings.gradle中添加

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

如果node_modules在工作空间根目录,../省略

在build.gradle

 dependencies {
compile project(':react-native-fetch-blob') }

在MainApplication或Activity添加包

import com.RNFetchBlob.RNFetchBlobPackage;

```
高版本下
 @Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new RNFetchBlobPackage(),
new MainReactPackage()
);
}

低版本下

 mReactRootView = new ReactRootView(this);
mReactInstanceManager = ReactInstanceManager.builder()
.addPackage(new RNFetchBlobPackage())
.build();
mReactRootView.startReactApplication(mReactInstanceManager, "Task", null);
setContentView(mReactRootView);

最近在项目中遇到:react-native-cached-image下react-native-fetch-blob报错

报错位置

采用rn版本如下:

"react": "^16.0.0-alpha.12",
"react-native": "^0.45.1",
修改react-native-cached-image如下版本后正常
"react-native-cached-image": "^1.2.5"

本文为博主原创文章,请尊重版权,未经博主允许不得转载,转载请注明出处:http://www.cnblogs.com/details-666/p/react-native-fetch-blob.html
执行下面命令或直接运行app
$ react-native run-android

undefined is not an object (evaluating 'RNFetchBlob.DocumentDir')的更多相关文章

  1. React-native-camera error with Expo: undefined is not an object (evaluating 'CameraManager.Aspect')

    React-native-camera error with Expo: undefined is not an object (evaluating 'CameraManager.Aspect') ...

  2. 使用react-navigation时报错:undefined is not an object (evaluating rngesturehandlermodule.direction)

    问题: 使用react-navigation时报错:undefined is not an object (evaluating rngesturehandlermodule.direction). ...

  3. react-native 编译报错: undefined is not an object (evaluating '_react2.PropTypes.func')

    情况通报: 因为是我的二维码模块报错,提示报错代码如下 重要信息是下面的红色字体部分(Android 模拟器红屏) undefined is not an object (evaluating '_r ...

  4. react-native 编译 undefined is not an object (evaluating '_react2.PropTypes.func')

    情况通报: 因为是我的二维码模块报错,提示报错代码如下 重要信息是下面的红色字体部分(Android 模拟器红屏) undefined is not an object (evaluating '_r ...

  5. undefined is not an object(evaluating '_react3.default.PropTypes.shape)

    手机红屏报这个错时的解决办法: npm uninstall --save react-native-deprecated-custom-components npm install --save ht ...

  6. undefined is not an object (evaluating '_react2.PropTypes.string')

    对所引用的组件原 .import React, {Component,PropTypes} from 'react' 改成:import React, {Component} from 'react' ...

  7. ReactNative踩坑日志——页面跳转之——Undefined is not an Object(evaluating this2.props.navigation.navigate)

    页面跳转时,报  Undefined is not an Object(evaluating this2.props.navigation.navigate) 出错原因:在一个页面组件中调用了另一个组 ...

  8. jquery TypeError: 'undefined' is not a function (evaluating 'elem.nodeName.toLowerCase()') [jquery.js:1904]错误原因

    今天,某个环境报了个js错误,TypeError: 'undefined' is not a function (evaluating 'elem.nodeName.toLowerCase()') [ ...

  9. 关于这个该死的报错:TypeError - 'undefined' is not a function (evaluating '_getTagName(currWindow).toLowerCase()')

    在利用Selenium爬取页面信息的时候突然报错,第一条信息爬取的时候还好好的,第二条就不行了. 请参考网上的爬取代码: # coding=utf-8"""Created ...

随机推荐

  1. html常用的知识点以及混合框架

    html中:   <hr/> 在页面中创建水平线 例如:   <p> p标签是定义段落   > alt 作为可预备可替换信息,在无法加载图片时显示文字信息   定义htm ...

  2. centos下的activemq的配置及PHP的使用

    一.安装JDK 1.下载JDK(官网:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.ht ...

  3. 【MySql】——MHA+GTID+failover+binlog-server+Atlas

    一.环境准备 1.mysql-db01 #系统版本 [root@mysql-db01 ~]# cat /etc/redhat-release CentOS release 6.7 (Final) #内 ...

  4. getRequestURI()与getRequestURL()的区别

    引于: http://hi.baidu.com/cloudxpc request.getRequestURI() 返回值类似:/xuejava/requestdemo.jsprequest.getRe ...

  5. Integer浅谈

    别BB,亮代码. 结果: 结果分析: 1.true 相信大家对第一个的比较结果应该不意外,只是单纯的数值比较 2.true 这个和第三个结果一比较起来就感觉迷惑了,明明两个都是同样的赋值方式,为什么一 ...

  6. abstract、virtual、sealed

    abstract与virtual前必有public 1.abstract,抽象 1)只要使用到了abstract定义了方法,那么类就一定得用abstract定义,public abstract,只有抽 ...

  7. ES6相关新特性介绍

    你可能已经听说过 ECMAScript 6 (简称 ES6)了.ES6 是 Javascript 的下一个版本,它有很多很棒的新特性.这些特性复杂程度各不相同,但对于简单的脚本和复杂的应用都很有用.在 ...

  8. PXC5.7集群部署

    PXC三节点安装: node1:10.157.26.132 node2:10.157.26.133 node3:10.157.26.134   配置服务器ssh登录无密码验证 ssh-keygen实现 ...

  9. zabbix_server表面启动成功,但是没有进程

    [root@iZ25m1box8cZ zabbix]# /etc/init.d/zabbix_server start Starting zabbix_server (via systemctl):  ...

  10. js快速去除数组重复项

    function unique1(arr) { var tmp = new Array(); tmp.push(arr[0]); for(var i=0;i<arr.length;i++) { ...