Search code examples
androidgradleversionconflicting-libraries

Gradle Version conflicts


My build.gradle was just fine until I tried updating sdk version (to 27) and lib versions.

In my build.gradle, I now have:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'

    implementation 'com.google.firebase:firebase-crash:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

I get an error msg:

  Please fix the version conflict either by updating the version of the google-services plugin 
(information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 15.0.1.

.. but it is 15.0.1 as you can see.

Also I have the wiggly red underline under

implementation 'com.android.support:appcompat-v7:27.1.1'

when I mouse-over, I get:

all support libraries must use the exact same version ... found versions 27.1.1 and 26.1.0

but I do not see any 26.1.0.

What am I doing wrong?


Solution

  • You need to update your main build.gradle file:

    if you are using android studio 3.1.2 then in your build.gradle file should look something like this:

      // Top-level build file where you can add configuration options common to all sub-projects/modules.
    
    buildscript {
        repositories {
            jcenter()
            google()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:3.1.3'
    
            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
            classpath 'com.google.gms:google-services:4.0.1' // you need to update this most probably.
        }
    }
    
    allprojects {
        repositories {
            google()
            jcenter()
            mavenCentral()
        }
    }
    
    task clean(type: Delete) {
        delete rootProject.buildDir
    }
    

    and in yours module's build.gradle file implement latest version for custom tabs in your case it's 27.1.1

    'com.android.support:customtabs:27.1.1'