【问题标题】:Error in flutter while using firebase_ml_vision使用 firebase_ml_vision 时出现颤振错误
【发布时间】:2020-11-03 11:56:54
【问题描述】:

当我在 pubspec.yaml 文件中使用或添加 firebase_ml_vision 时,我的应用会显示这些错误。

如果我在 pubspec yaml 中删除 firebase_ml_vision,一切都会好起来的。

我只是按照从集成 firebase 到将 implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.1' 添加到 app/build.gradle 的所有过程。

但我只是卡在这里。

我不知道怎么解决。

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.1.
  0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

  Dependency failing: com.google.android.gms:play-services-vision-image-label:18.0.4 -> com.google.android.gms:play-servic
  es-vision-common@[19.1.0], but play-services-vision-common version was 19.1.2.
                                                                                
  The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
  ifact with the issue.
  -- Project 'app' depends onto com.google.firebase:firebase-ml-vision@{strictly 24.1.0}
  -- Project 'app' depends onto com.google.android.gms:play-services-vision-common@{strictly 19.1.2}
  -- Project 'app' depends on project 'firebase_ml_vision' which depends onto com.google.firebase:firebase-ml-vision@20.0.
  0
  -- Project 'app' depends onto com.google.android.gms:play-services-mlkit-text-recognition@{strictly 16.1.1}
  -- Project 'app' depends onto com.google.android.gms:play-services-mlkit-text-recognition@16.1.1
  -- Project 'app' depends onto com.google.firebase:firebase-bom@26.0.0 
  -- Project 'app' depends onto com.google.android.gms:play-services-vision-image-label@{strictly 18.0.4}
  -- Project 'app' depends onto com.google.firebase:firebase-bom@{strictly 26.0.0}
  -- Project 'app' depends onto com.google.android.gms:play-services-vision@{strictly 20.1.2}

  For extended debugging info execute Gradle from the command line with ./gradlew --info :app:assembleDebug to see the dep
  endency paths to the artifact. This error message came from the google-services Gradle plugin, report issues at https://
  github.com/google/play-services-plugins and disable by adding "googleServices { disableVersionCheck = true }" to your bu
  ild.gradle file.

我在项目级别的 build.gradle

buildscript {
    '''
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.4'
    }
}

我在应用级别的 build.gradle

'''
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

'''
android {
    '''
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        '''
        minSdkVersion 21
        targetSdkVersion 28
        '''
    }
    '''
}
'''
dependencies {
   '''
    implementation platform('com.google.firebase:firebase-bom:26.0.0')
    implementation 'com.google.android.gms:play-services-mlkit-text-recognition:16.1.1'
}

【问题讨论】:

  • 这可能是由于 play-services-mlkit-text-recognition 和 firebase_ml_vision 对 play-services-vision-common 的版本要求不同。为什么两者都需要?后一种已被新的 ML Kit 弃用。 developers.google.com/ml-kit/migration/android

标签: flutter firebase-mlkit


【解决方案1】:

我设法使用 firebase-bom:24:0.0 而不是 26:0.0 解决了类似的问题。

【讨论】:

    【解决方案2】:

    我们对 Firebase ML Kit 进行了一些更改,以更好地区分设备端 API 和基于云的 API。 “ML Kit”(没有 Firebase 品牌)包含所有设备上的 API。 Here's 从 firebase mlkit 到 mlkit 的迁移指南。

    对于这个特定的依赖问题,firebase mlkit 依赖存在一个已知问题。有解释here

    删除 firebase mlkit 愿景,依赖 com.google.android.gms:play-services-mlkit-text-recognition:16.1.1 并使用 MLKit API 应该是正确的做法。

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题。 试过了

      gradle-6.1.1-all.zip, 
      implementation 'com.google.android.gms:play-services-vision:20.1.2'
      implementation 'com.google.android.gms:play-services-vision-common:19.1.2'
      implementation 'com.google.android.gms:play-services-vision-image-label:18.1.0'
      

      关于这个问题的任何更新?

      【讨论】:

        猜你喜欢
        • 2020-04-01
        • 2021-06-17
        • 1970-01-01
        • 2021-03-20
        • 2021-10-31
        • 2021-04-04
        • 2023-04-02
        • 2020-06-20
        • 2021-05-13
        相关资源
        最近更新 更多