Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding WHY gradle complains about colliding versions

I have been trying to bring back an old app of mine, that I wrote a while back using eclipse. I imported to android-studio and I it complains about colliding versions:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha1, 27.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-alpha1 and com.android.support:cardview-v7:27.1.0

At first, I solved it as suggested by this question, by including the colliding packages specifically in the gradle file with the newer version. So my gradle file ended up like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "com.tomklino.imhere"
        minSdkVersion 16
        targetSdkVersion 19
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }


    dependencies {
        implementation 'com.android.support:appcompat-v7:+'
        implementation 'com.android.support:cardview-v7:27.1.0'
        implementation 'com.android.support:customtabs:27.1.0'
        implementation 'com.android.support:support-media-compat:27.1.0'
        implementation 'com.android.support:support-v4:27.1.0'
        implementation 'com.loopj.android:android-async-http:1.4.9'
        implementation "com.google.android.gms:play-services-gcm:11.8.0"
        implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
    }

    apply plugin: 'com.google.gms.google-services'
}

This removed the red line from under the appcompat line, but then, after debugging something else, I got the message above again, but this time with the version 28.0.0-alpha1. Now I can't include the new version, because if I try it says it is incompatible with the sdk version of 27.

I'm trying to understand why it asks for that version in the first place if I havn't included that sdk version anywhere. Nothing in the dependency tree asks for the 28.0.0-alpha1 version specifically.

like image 779
Tom Klino Avatar asked Mar 12 '18 12:03

Tom Klino


1 Answers

but then, after debugging something else, I got the message above again, but this time with the version 28.0.0-alpha1

Replace:

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

with:

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

and resolve to stop using + for the entire version of an artifact.

I'm trying to understand why it asks for that version in the first place if I havn't included that sdk version anywhere.

You used + for the version of appcompat-v7. This says that you want the latest that Gradle can find. And, last week, Google released 28.0.0-alpha1, in tandem with the release of the Android P Developer Preview 1.

like image 75
CommonsWare Avatar answered Oct 08 '22 07:10

CommonsWare