首页 > 解决方案 > React Native:使用 react-native-fs 时出现异常

问题描述

https://i.stack.imgur.com/v5Bk4.jpg

这是使用 React-native-fs 时的错误。我正在使用 expo 创建我的项目而没有分离,并尽量不分离。我想从 react-native 模块读取从 CameraRoll 中的 getPhotos 检索到的 content:// 图像作为文件路径。是不是因为我没有分离我的应用程序。有没有办法使用 expo 来检索图像的文件路径。

标签: react-nativefilesystemsexpo

解决方案


You should link project

react-native link react-native-fs

or manual linking

android/settings.gradle
...
include ':react-native-fs'
project(':react-native-fs').projectDir = new File(settingsDir, '../node_modules/react-native-fs/android')
android/app/build.gradle
...
dependencies {
    ...
    compile project(':react-native-fs')
}

添加包 .addPackage(new RNFSPackage())

然后生成新版本


推荐阅读