我想使用这个库:
react-native-document-picker
https://github.com/Elyx0/react-native-document-picker
我按照以下步骤操作:
npm i --save react-native-document-picker
react-native link
我想在Android设备上运行我的项目:
Incremental java compilation is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApk'.
> Configuration with name 'default' not found.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
一切正常,然后再安装。
我不知道我的问题在哪里,我也不知道该怎么解决!
build.gradle:
dependencies {
compile project(':react-native-document-picker')
compile project(':react-native-contacts')
compile project(':react-native-vector-icons')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
setting.gradle:
include ':react-native-document-picker'
project(':react-native-document-picker').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-document-picker/android')
include ':react-native-contacts'
project(':react-native-contacts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-contacts/android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android')
include ':app'
MainApplication.java:
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeDocumentPicker(),
new ReactNativeContacts(),
new VectorIconsPackage()
);
}
答案 0 :(得分:1)
我不是专家,但这是我从测试中发现的。
不幸的是,npm i --save react-native-document-picker
卸载了项目中的所有其他软件包。因此,在执行npm i --save react-native-document-picker
之后,
npm install
。它将安装缺少的软件包。然后react-native link
来链接库。Android Studio
打开android项目目录。建议您升级gradle版本。接受它,然后重建项目。 就是这样。有效的源代码可以从here
中找到让我知道它是否对您有用。