【问题标题】:React Native 'run-android' mac issueReact Native 'run-android' mac 问题
【发布时间】:2019-10-25 10:26:48
【问题描述】:

我有一个在 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

我已经下载了 Android Studio,设置了一个虚拟设备,安装了必要的 JDK。

我该如何解决?

完整的错误信息:

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'.

【问题讨论】:

    标签: android react-native


    【解决方案1】:

    在 android/app/build.gradle 中添加这段代码

    android {
      ...
      defaultConfig {
        ...
        missingDimensionStrategy 'react-native-camera', 'general' <-- insert this line
      }
    }
    

    【讨论】:

      【解决方案2】:

      我相信你必须在你的android/app/build.gradle 中设置变量。

      阅读此处了解更多详情(第 4 点):https://react-native-community.github.io/react-native-camera/docs/installation

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-05-16
        • 1970-01-01
        • 2019-12-23
        • 2019-06-26
        • 1970-01-01
        • 2017-05-12
        相关资源
        最近更新 更多