1

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?

Umair
  • 6,366
  • 15
  • 42
  • 50
j3App
  • 1,510
  • 1
  • 17
  • 26
  • can you post your complete build.gradle file ? – Umair Jun 21 '18 at 10:32
  • 1
    It usually specifies the name of the library that has the versions. Some of the dependencies are using an older version internally, just take the library that is mentioned to have version 26 and add it with version 27 – Suleyman Jun 21 '18 at 10:33
  • Try use the same version from every library under com.android.support package – Zach Bublil Jun 21 '18 at 10:37
  • 1
    _"but I do not see any 26.1.0"_ Then you probably depend on it indirectly through some other dependency. You can run `gradlew app:dependencies` from the command line to get a dependency tree for your project. – Michael Jun 21 '18 at 10:37
  • 2
    take a look here https://stackoverflow.com/questions/50900152/android-suport-libraries-must-use-the-exact-same-version/50900461#50900461 – E.Abdel Jun 21 '18 at 10:39
  • yes, in libraries I have Gradle__com_android_support_customtabs_26_1_0.xml, a small xml file. How can I upgrade it to 27.1.1. Just by renaming? – j3App Jun 21 '18 at 10:40
  • @sunilsunny 15.0.1 is the latest version. Please check before posting a comment :) – Umair Jun 21 '18 at 10:41
  • @Umair oops my bad tnx for pointing. – Sunil Sunny Jun 21 '18 at 10:44
  • the wiggly line was removed afet I added : implementation 'com.android.support:customtabs:27.1.1' to my dependencies. I do not know why that was necessary. Thanks a lot to E.Abdel for giving me a hint in the right direction – j3App Jun 21 '18 at 10:54

4 Answers4

2

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'
Umair
  • 6,366
  • 15
  • 42
  • 50
  • Thanks Umair, the 'com.google.gms:google-services:4.0.1' did the trick (I had an older version). Now I just need to get the problem with the red wiggly line fixed – j3App Jun 21 '18 at 10:46
  • yes, but the red wiggly line is due to me having Gradle__com_android_support_customtabs_26_1_0.xml in libraries. I need to get it updated, but do not know why I have the problem in the 1st place and how to fix – j3App Jun 21 '18 at 10:49
  • @j3App you can delete that file and sync again it will solve the problem. You got the problem because most probably you were using version 26 before ? – Umair Jun 21 '18 at 10:52
  • deleting and resyncing didn't do it for me. I had to add "implementation 'com.android.support:customtabs:27.1.1'" in my build.gradle. Anyway; thanks a lot for helping me out – j3App Jun 21 '18 at 11:13
  • @j3App and it did work for me. Android never fails to amaze you ... Happy Coding :) – Umair Jun 21 '18 at 11:20
1

Go to android studio and press File -> Invalidate Caches / Restart in the appeared window press Invalidate and Restart, The problem may be in Cached version, Worked for me)

0

I too had similar issues. After updating. Luckily got this resolved after going through many threads.

As you are using Firebase, I recommend updated crashlytics. As older version is deprecated.

buildscript {

    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.fabric.io/public'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1' 
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url 'https://maven.google.com/'
        }
    }
}

Now for dependencies

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

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.app.abc"
        minSdkVersion 19
        targetSdkVersion 27
        ......
        }
}

dependencies {
    api fileTree(dir: 'libs', include: ['*.jar'])
    api 'com.android.support:appcompat-v7:27.1.1'
    api 'com.android.support:support-v4:27.1.1'
    api 'com.android.support:design:27.1.1'


    //crash analytics
    api 'com.crashlytics.sdk.android:crashlytics:2.9.3'
    api 'com.google.firebase:firebase-crash:11.8.0'

    //Google Maps. You can avoid this, as I was using location services as well
    api 'com.google.android.gms:play-services-maps:12.0.1'
    api 'com.google.android.gms:play-services-places:12.0.1'
    api 'com.google.android.gms:play-services:12.0.1'
    api 'com.google.android.gms:play-services-location:12.0.1'

  }
Sreehari
  • 5,621
  • 2
  • 25
  • 59
0

The error says you have a conflict of dependancies . I have faced this once with the expresso test. What you have to do is exclude the other dependencies of the expresso test library . This stack post may help

androidTestCompile ('com.android.support.test.espresso:espresso-core:3.0.2'){
    exclude module: 'support-annotations'
    exclude module: 'support-v4'
    exclude module: 'support-v13'
    exclude module: 'recyclerview-v7'
    exclude module: 'design'
}
SproutinGeek
  • 327
  • 3
  • 19