[RN] React Native 使用 react-native-camera 过程中报错 Found react-native-camera 'mlkit' but wasn
Posted wukong1688
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[RN] React Native 使用 react-native-camera 过程中报错 Found react-native-camera 'mlkit' but wasn相关的知识,希望对你有一定的参考价值。
详细报错如下:
Could not resolve all task dependencies for configuration ‘:app:debugRuntimeClasspath‘.
Could not resolve project :react-native-camera.
Required by:
project :app
> Cannot choose between the following configurations of project :react-native-camera:
- generalDebugRuntimeElements
- mlkitDebugRuntimeElements
All of them match the consumer attributes:
- Configuration ‘generalDebugRuntimeElements‘:
- Required com.android.build.api.attributes.BuildTypeAttr ‘debug‘ and found compatible value ‘debug‘.
- Found com.android.build.api.attributes.VariantAttr ‘generalDebug‘ but wasn‘t required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar‘ and found compatible value ‘Aar‘.
- Required org.gradle.usage ‘java-runtime‘ and found compatible value ‘java-runtime‘.
- Found react-native-camera ‘general‘ but wasn‘t required.
- Configuration ‘mlkitDebugRuntimeElements‘:
- Required com.android.build.api.attributes.BuildTypeAttr ‘debug‘ and found compatible value ‘debug‘.
- Found com.android.build.api.attributes.VariantAttr ‘mlkitDebug‘ but wasn‘t required.
- Required com.android.build.gradle.internal.dependency.AndroidTypeAttr ‘Aar‘ and found compatible value ‘Aar‘.
- Required org.gradle.usage ‘java-runtime‘ and found compatible value ‘java-runtime‘.
- Found react-native-camera ‘mlkit‘ but wasn‘t required.`
解决办法:
android/app/build.gradle
增加:
missingDimensionStrategy ‘react-native-camera‘, ‘general‘
in defaultConfig
同时在android/build.gradle 中:
增加
maven url "https://jitpack.io" maven url "https://maven.google.com"
参考:
https://github.com/react-native-community/react-native-camera/issues/2150
以上是关于[RN] React Native 使用 react-native-camera 过程中报错 Found react-native-camera 'mlkit' but wasn的主要内容,如果未能解决你的问题,请参考以下文章
React Native开发之expo中camera的基本使用
react-native聊天室|RN版聊天App仿微信实例|RN仿微信界面
如何使用 React Navigation 6.x Native Stack Navigator (RN>0.6) 实现 React-native-gesture-handler?