简体   繁体   English

无法解决 React Native Camera MLKit 依赖项

[英]Can not Resolve React Native Camera MLKit Dependencies

My app builds fine on Android Studio, it runs fine with react-native run-android but when I try to generate the .apk it fails with ./gradlew assembleRelease command.我的应用程序在 Android Studio 上构建良好,它在react-native run-android上运行良好,但是当我尝试生成.apk时,它会因./gradlew assembleRelease命令而失败。 I get the following error.我收到以下错误。

Error Message错误信息

* 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 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",

gradle properties gradle 属性

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

I have followed the installation instructions here and followed GitHub links here and here .我已按照此处的安装说明进行操作,并按照此处此处的 GitHub 链接进行操作。

All have the same solution which I have completed, ie adding;所有人都有我完成的相同解决方案,即添加;

android/app/build.gradle android/app/build.gradle

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

Note笔记

The issue is because android is looking for mlkit dependencies even when I have not opted for them.问题是因为 android 正在寻找mlkit依赖项,即使我没有选择它们。 I think this is happening because I use react-native-image-picker and react-native-qrcode-scanner one of these packages is looking mlkit dependencies.我认为这是因为我使用react-native-image-picker picker 和react-native-qrcode-scanner这些软件包之一正在寻找 mlkit 依赖项。 But I don't know how to debug and fix it.但我不知道如何调试和修复它。

Be sure that in the android/app/build.gradle you added this确保在 android/app/build.gradle 你添加了这个

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

Then check your internet connectivity is good while building.然后在构建时检查您的互联网连接是否良好。 If it doesn't work, use npm run release如果还不行,使用 npm 运行发布

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM