我正在使用react-native-photo-upload库上传个人资料图片,但它抛出构建失败错误

时间:2019-01-18 16:54:22

标签: javascript android reactjs react-native

我使用的库是https://www.npmjs.com/package/react-native-photo-uploadyarn add react-native-photo-upload 并引发以下错误:

**/home/haseeb/Desktop/RN/myProject/node_modules/react-native-image-picker/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.

/home/haseeb/Desktop/RN/myProject/node_modules/react-native-image-picker/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
:react-native-image-picker:processReleaseResources FAILED

**FAILURE**: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-image-picker:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 5.653 secs
Could not install the app on the device, read the error above for details.
Make sure you have an Android emulator running or a device connected and have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html**

我在react-native-image-picker的gradle.properties中尝试了android.enableAapt2=false,但没有获得收益...相同错误

请帮助解决该问题!

1 个答案:

答案 0 :(得分:0)

运行yarn add react-native-photo-upload 后,请务必遵循库中的说明,您需要确保链接包并重新构建项目:

react-native link react-native-image-picker
react-native link react-native-image-resizer
react-native link react-native-fs

之后,您可以转到yourProject/android/settings.gradle并验证是否已添加所有模块。它可能看起来像:

include ':module-name'
project(':module-name').projectDir = new File(rootProject.projectDir, 
'../node_modules/module-name/android')

您也可以转到yourProject/android/app/build.gradle检查模块是否存在于依赖项中:

dependencies {
    compile project(':module-name')
}