简体   繁体   English

Firebase ML-vision 和 admob 插件在同一个 Flutter 项目问题 - 播放服务版本冲突

[英]Firebase ML-vision and admob plugins in same Flutter project problem - play services version conflict

Getting really frustrated with this - so I have a project in Flutter with these dependecies among others:对此感到非常沮丧 - 所以我在 Flutter 中有一个项目,其中包含这些依赖项:

firebase_admob: ^0.10.2
firebase_ml_vision: ^0.9.9

While I had only firebase_ml_vision everything compile smoothly, but adding admob changed that and now the error I'm getting is this:虽然我只有firebase_ml_vision一切都可以顺利编译,但添加 admob 改变了这一点,现在我得到的错误是这样的:

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.0.
  2]", 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:20.0.0 -> com.google.android.gms:play-services-vision-co
  mmon@[19.0.2], but play-services-vision-common version was 19.1.0.

  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 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-vision-common@{strictly 19.1.0}
  -- Project 'app' depends onto com.google.android.gms:play-services-vision-image-label@{strictly 18.0.4}
  -- Project 'app' depends onto com.google.android.gms:play-services-vision@{strictly 20.0.0}

  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.

So far I tried everything I could think of, including juggling versions and so on.到目前为止,我尝试了我能想到的一切,包括杂耍版本等等。

Is there any way to fix this?有没有什么办法解决这一问题?

UPDATE更新

After some more experiments, I added googleServices.disableVersionCheck = true to my build.gradle, so apparently, apart from many deprecation warnings (hello Firebase), this is the real problem:经过一些更多的实验,我在 build.gradle 中添加了googleServices.disableVersionCheck = true ,所以显然,除了许多弃用警告(你好 Firebase),这是真正的问题:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:checkDebugDuplicateClasses'.
> 1 exception was raised by workers:
  java.lang.RuntimeException: Duplicate class com.google.android.gms.internal.vision.zze found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzf found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzg found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzh found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzi found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzv found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)
  Duplicate class com.google.android.gms.internal.vision.zzw found in modules jetified-play-services-vision-20.0.0-runtime.jar (com.google.android.gms:play-services-vision:20.0.0) and jetified-play-services-vision-common-19.1.0-runtime.jar (com.google.android.gms:play-services-vision-common:19.1.0)

  Go to the documentation to learn how to <a href="d.android.com/r/tools/classpath-sync-errors">Fix dependency resolution errors</a>.

Still no solution though.不过还是没有解决办法。

UPDATE 2更新 2

While looking for way to fix this, I found this set of tips to fix the "known issue": https://firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes在寻找解决此问题的方法时,我发现了这组提示来解决“已知问题”: https : //firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes

Authors of the Flutter plugin could, I don't know, try implement them too?!我不知道 Flutter 插件的作者也可以尝试实现它们?!

So I tried to implement it, obvious place was the build.gradle file of the firebase_ml_vision library (I didn't want to make a fork on github, so just for testing purposes edited the file on my drive), I changed one line and added two more from the "solution" linked above:所以我尝试实现它,明显的地方是 firebase_ml_vision 库的 build.gradle 文件(我不想在 github 上创建一个 fork,所以只是为了测试目的编辑了我驱动器上的文件),我更改了一行并从上面链接的“解决方案”中添加了两个:

        api 'com.google.firebase:firebase-ml-vision:24.1.0'
        implementation 'com.google.android.gms:play-services-vision:20.1.1'
        implementation 'com.google.android.gms:play-services-vision-common:19.1.1'

Original line had the firebase-ml-vision:20.0.0原始线有firebase-ml-vision:20.0.0

Compilation failed again, BUT, I didn't give up and went one step further to just try make this work and for whatever reason decided to try comment out the line apply plugin: 'com.google.gms.google-services' in my project's android/app/build.gradle file.编译再次失败,但是,我没有放弃并更进一步尝试使这项工作正常工作,无论出于何种原因决定尝试注释掉我的apply plugin: 'com.google.gms.google-services'项目的android/app/build.gradle文件。 With this change the project finally compiled, but of course, having it disabled caused other problems, like application not initializing the Firebase plugin, so in the end it's still a failure.通过此更改,项目最终编译,但当然,禁用它会导致其他问题,例如应用程序未初始化 Firebase 插件,因此最终它仍然失败。 The search continues...搜索还在继续……

UPDATE 3更新 3

Third time's the charm - I decided to fiddle with it a bit more and again added googleServices.disableVersionCheck = true to my gradle file.第三次是魅力所在——我决定多花些功夫,并再次将googleServices.disableVersionCheck = true添加到我的 gradle 文件中。 It worked.有效。 Project compiles, Firebase init goes okay and even the admob banner shows, although spewing errors on every refresh.项目编译,Firebase init 运行正常,甚至显示 admob 横幅,尽管每次刷新时都会出现错误。 Sigh.叹。 This is barely a solution, whoever makes decisions on when to push such libraries (with "self-serve" fixes like this mess) into production should be very ashamed.这几乎不是一个解决方案,任何人决定何时将这些库(带有像这种烂摊子这样的“自助式”修复)推向生产环境的人都应该感到非常羞耻。

I experienced this same issue with Firebase libraries, you should be able to put any next to the version of the library like so:我在使用 Firebase 库时遇到了同样的问题,您应该可以像这样在库版本旁边放置any

firebase_admob: any
firebase_ml_vision: any

Then run flutter pub get然后运行flutter pub get

Then check you pubspec.lock file and check the versions for the libraries then fill them in the pubspec.yaml file.然后检查pubspec.lock文件并检查库的版本,然后将它们填充到pubspec.yaml文件中。

Your conflicts should be gone then.你的冲突应该消失了。

Let me know if I misunderstood your question or you need further explaining!如果我误解了您的问题,或者您需要进一步解释,请告诉我!

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

相关问题 "Firebase ML Vision 软件包因颤振而停产" - Firebase ML Vision package is DISCONTINUED for flutter Flutter firebase_ml_vision 错误与异步函数、getImage 和pickFile - Flutter firebase_ml_vision errors with async function, getImage and pickedFile Flutter firebase_ml_vision 构建失败,出现异常 - Flutter firebase_ml_vision build failed with exception 在同一个Android项目中使用不同版本的Firebase和Google Play服务? - Use different versions of Firebase and Google Play Services in same Android project? Flutter firebase 版本冲突 firebase 消息传递 - Flutter firebase version conflict firebase messaging 在 Flutter 上的 firebase_ml_vision 中计算人脸的函数 - Function to count faces in firebase_ml_vision on Flutter 在Firebase ml视觉颤动中,Face对象的属性始终为null - Attributes of Face object is always null in firebase ml vision flutter Firebase 和 Play-Services 之间的另一个版本冲突:com.google.android.gms:play-services-measurement-base - Another version conflict between Firebase and Play-Services: com.google.android.gms:play-services-measurement-base 添加Play Services依赖关系会与Firebase发生冲突 - Adding Play Services dependency causes a conflict with Firebase flutter版本与位置和firebase_messaging冲突 - flutter version conflict with location and firebase_messaging
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM