React-native 文件选择器react-native-file-selector的使用

最后是错误解决办法,本文只说明安装方法,具体使用查看https://github.com/prscX/react-native-file-selector

 

1、npm install react-native-file-selector –save

2、最好不要自动 link     –react-native link react-native-file-selector

 

手动link步骤

A、在android\settings.gradle添加

include ‘:react-native-file-selector’

project(‘:react-native-file-selector’).projectDir = new File(rootProject.projectDir, ‘../node_modules/react-native-file-selector/android’)

 

B、在android\build.gradle添加

maven { url “http://dl.bintray.com/lukaville/maven” }

《React-native 文件选择器react-native-file-selector的使用》

 

C、在android\app\build.gradle中添加

implementation project(‘:react-native-file-selector’)

《React-native 文件选择器react-native-file-selector的使用》

 

D、在MainApplication.java中引用jar包

import ui.fileselector.RNFileSelectorPackage;

在getPackages()中使用

new RNFileSelectorPackage(),

《React-native 文件选择器react-native-file-selector的使用》

 

3、添加选择文件主题颜色,可以自定义

增加文件android/app/src/main/res/values/colors.xml

《React-native 文件选择器react-native-file-selector的使用》

 

4、添加权限 android\app\src\main\AndroidManifest.xml

<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE” />

 

 

 

 

记一下的原因是安装依赖,自动link后出现各种报错,和之前引用的依赖冲突,或者打包报错

Execution failed for task ‘:app:transformClassesWithMultidexlistForDebug’.

> java.io.IOException: Can’t write [D:\Work\drp_admin_app\android\app\build\intermediates\multi-dex\debug\componentClasses.jar] (Can’t read [C:\Users\Admin\.gradle\caches\transforms-1\files-1.1\support-core-ui-27.1.0.aar\b6c4178a4c08c4dfa3ddaf1b25f9d379\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [classes.jar:android/support/design/widget/CoordinatorLayout$Behavior.class]))

我的解决办法

在android/app/build.gradle中加入

《React-native 文件选择器react-native-file-selector的使用》

 

《React-native 文件选择器react-native-file-selector的使用》

 

还有一些其他的我尝试了没有用,也记一下

《React-native 文件选择器react-native-file-selector的使用》

或者是implementation  ‘com.android.support:multidex:1.0.3’

这些都是老的sdk版本

 

 

 

    原文作者:移动开发
    原文地址: https://my.oschina.net/HhhXxxJjj/blog/1936008
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞