[英]React Native 'run-android' mac issue
I have a react-native project that successfully runs on iOS emulator however, when running react-native run-android
I get the following error:我有一个在 iOS 模拟器上成功运行的 react-native 项目但是,在运行
react-native run-android
时出现以下错误:
error Failed to install the app. Make sure you have the Android development environment set up
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
I have downloaded Android studio, setup a virtual device, installed necessary JDK.我已经下载了Android studio,设置了一个虚拟设备,安装了必要的JDK。
How can I resolve?我该如何解决?
Full error message:完整的错误信息:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> 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 variants of project :react-native-camera:
- generalDebugRuntimeElements
- mlkitDebugRuntimeElements
All of them match the consumer attributes:
- Variant 'generalDebugRuntimeElements' capability VerizonApp:react-native-camera:unspecified:
- Unmatched attributes:
- Found com.android.build.api.attributes.VariantAttr 'generalDebug' but wasn't required.
- Found react-native-camera 'general' but wasn't required.
- Compatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- 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'.
- Variant 'mlkitDebugRuntimeElements' capability VerizonApp:react-native-camera:unspecified:
- Unmatched attributes:
- Found com.android.build.api.attributes.VariantAttr 'mlkitDebug' but wasn't required.
- Found react-native-camera 'mlkit' but wasn't required.
- Compatible attributes:
- Required com.android.build.api.attributes.BuildTypeAttr 'debug' and found compatible value 'debug'.
- 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'.
Add this code in android/app/build.gradle将此代码添加到 android/app/build.gradle
android {
...
defaultConfig {
...
missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line
}
}
I believe you have to set the variant in your android/app/build.gradle
.我相信您必须在
android/app/build.gradle
中设置变体。
Read here for more details (Point number 4): https://react-native-community.github.io/react-native-camera/docs/installation阅读此处了解更多详细信息(第 4 点): https://react-native-community.github.io/react-native-camera/docs/installation
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.