title: Firebase ML-vision and admob plugins in same Flutter project problem - play services version conflict
body: <p>Getting really frustrated with this - so I have a project in Flutter with these dependecies among others:</p>
  <pre><code>firebase_admob: ^0.10.2
  firebase_ml_vision: ^0.9.9
  </code></pre>
  <p>While I had only <code>firebase_ml_vision</code> everything compile smoothly, but adding admob changed that and now the error I'm getting is this:</p>
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
  &gt; In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. &quot;[19.0.
    2]&quot;, 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 -&gt; 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 &quot;googleServices { disableVersionCheck = true }&quot; to your bu
    ild.gradle file.
  </code></pre>
  <p>So far I tried everything I could think of, including juggling versions and so on.</p>
  <p>Is there any way to fix this?</p>
  <p><em>UPDATE</em></p>
  <p>After some more experiments, I added <code>googleServices.disableVersionCheck = true</code> to my build.gradle, so apparently, apart from many deprecation warnings (hello Firebase), this is the real problem:</p>
  <pre><code>FAILURE: Build failed with an exception.
  
  * What went wrong:
  Execution failed for task ':app:checkDebugDuplicateClasses'.
  &gt; 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 &lt;a href=&quot;d.android.com/r/tools/classpath-sync-errors&quot;&gt;Fix dependency resolution errors&lt;/a&gt;.
  </code></pre>
  <p>Still no solution though.</p>
  <p><em>UPDATE 2</em></p>
  <p>While looking for way to fix this, I found this set of tips to fix the &quot;known issue&quot;: <a href="https://firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes" rel="nofollow noreferrer">https://firebase.google.com/support/release-notes/android#mlkit-self-serve-fixes</a></p>
  <p>Authors of the Flutter plugin could, I don't know, try implement them too?!</p>
  <p>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 &quot;solution&quot; linked above:</p>
  <pre><code>        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'
  </code></pre>
  <p>Original line had the <code>firebase-ml-vision:20.0.0</code></p>
  <p>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 <code>apply plugin: 'com.google.gms.google-services'</code> in my project's <code>android/app/build.gradle</code> file.
  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. The search continues...</p>
  <p><em>UPDATE 3</em></p>
  <p>Third time's the charm - I decided to fiddle with it a bit more and again added <code>googleServices.disableVersionCheck = true</code> to my gradle file. It worked. Project compiles, Firebase init goes okay and even the admob banner shows, although spewing errors on every refresh. Sigh. This is barely a solution, whoever makes decisions on when to push such libraries (with &quot;self-serve&quot; fixes like this mess) into production should be very ashamed.</p>