无法解决React Native Camera MLKit依赖关系

时间:2019-10-11 13:07:10

标签: android react-native gradle react-native-android

我的应用程序在Android Studio上运行良好,可以在react-native run-android上正常运行,但是当我尝试生成.apk时,它会通过./gradlew assembleRelease命令失败。我收到以下错误。

错误消息

* What went wrong:
Could not determine the dependencies of task ':react-native-camera:compileMlkitReleaseAidl'.
> Could not resolve all task dependencies for configuration ':react-native-camera:mlkitReleaseCompileClasspath'.
   > Could not find com.google.firebase:firebase-ml-vision:12.0.1.
     Required by:
         project :react-native-camera
   > Could not find com.google.firebase:firebase-ml-vision-face-model:12.0.1.
     Required by:
         project :react-native-camera

package.json

    "react": "16.8.3",
    "react-native": "0.59.10",
    "react-native-camera": "^3.7.1",
    "react-native-image-picker": "^0.28.1",
    "react-native-qrcode-scanner": "^1.2.3",

渐变属​​性

classpath('com.android.tools.build:gradle:3.4.0') // FROM android/gradle.build
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip // FROM gradle-wrapper.properties

我已遵循安装说明here,并遵循了GitHub链接herehere

所有人都有我已经完成的相同解决方案,即添加;

android / app / build.gradle

android {
  defaultConfig {
    missingDimensionStrategy 'react-native-camera', 'general'
  }
}

注意

问题是因为即使我没有选择mlkit依赖项,android也在寻找它们。我认为这是因为我使用了react-native-image-pickerreact-native-qrcode-scanner这些软件包之一来寻找mlkit依赖关系。但是我不知道如何调试和修复它。

1 个答案:

答案 0 :(得分:0)

请确保您在android / app / build.gradle中添加了此

missingDimensionStrategy 'react-native-camera', 'general' in *defaultConfig*

然后在构建时检查Internet连接是否良好。 如果不起作用,请使用     npm运行发行版