1. Could not find com.nbsp:library:1.8.
(1) 在./android/app/build.gradle目录中添加implementation 'com.android.support:design:27.1.1这一行, 如下所示:
repositories {
maven {
url "http://dl.bintray.com/lukaville/maven"
}
}
dependencies {
implementation project(':react-native-file-selector') // add
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'com.android.support:design:27.1.1'
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
compile 'com.android.support:support-v4:27.0.2'
implementation "com.facebook.react:react-native:+" // From node_modules
}
(2) In android/app/src/main/res/values I created colors.xml file.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="primary_dark">#000000</color>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
(3) 在AndroidManifest文件中添加权限。
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
使用:
import RNFileSelector from 'react-native-file-selector';
RNFileSelector.Show({
title: 'Select File',
onDone: (path) => {
console.log('file selected: ' + path);
},
onCancel: () => {
console.log('cancelled');
},
});