2 votes

Problem when building application: "You should manually set the same version via DependencyResolution"

I just updated one of my projects by changing dependencies with new versions, but now I have a problem indicates to me that the construction failure (Build failed) and shows me on the screen of the Build the following error message:

Android dependency 'com.android.support:cardview-v7' has different version for the compile (27.0.2) and runtime (27.1.1) classpath. You should manually set the same version via the DependencyResolution

My file build.gradle is the following:

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.4'
    }
}

repositories { 
    mavenCentral()
    maven { url 'https://maven.fabric.io/public' }
    google()
}

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        applicationId "xxx.xxxxxxxxxx.fussbal"
        minSdkVersion 15
        targetSdkVersion 26
        versionCode 25
        versionName '1.8.3'
        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true
    }
    dexOptions {
        javaMaxHeapSize "2048M"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'jsr305_annotations/Jsr305_annotations.gwt.xml'
        exclude 'error_prone/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Annotations.gwt.xml'
        exclude 'third_party/java_src/error_prone/project/annotations/Google_internal.gwt.xml'
    }
    lintOptions {
        disable 'MissingTranslation'
    }
}

dependencies {
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation project(':AndRoboDroid')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    //implementation 'com.squareup.okhttp:okhttp:2.5.0'
    //implementation 'com.android.support:multidex:1.0.2'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.0.0'
    //implementation 'com.google.android.gms:play-services-base:11.6.0'
    implementation 'com.google.android.gms:play-services-ads:12.0.0'
    implementation 'com.google.android.exoplayer:exoplayer:2.6.1'
    implementation('com.crashlytics.sdk.android:crashlytics:2.9.3@aar') {
        transitive = true;
    }
}

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

it should be noted that the library AndRoboDroid ( implementation project(':AndRoboDroid')) to which reference is made in the file build.gradle main, was also updated to :

apply plugin: 'com.android.library'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 26
        vectorDrawables.useSupportLibrary = true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
    }
    lintOptions {
        disable 'MissingTranslation'
    }
}

dependencies {
    api files('libs/OoyalaSDK.aar')
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.appnexus.opensdk:appnexus-sdk:4.5'
    implementation('com.crashlytics.sdk.android:answers:1.4.2@aar') {
        transitive = true;
    }
}

This is what I have done with the previous configuration:

  • To ensure in all, the project does not have versions 27.0.2 as the error indicates.
  • I re-started the IDE.
  • Clean the project, even delete the contents of the directory /build

2voto

Elenasys Points 67941

In fact the problem is that the project was using CardViews and the library had the definitions with the version 27.0.2 but are not found when performing a search because they were within .JAR

introducir la descripción de la imagen aquí

Within the main project in my file, build.gradle I added also the definition of the library cardview:

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
//***Agregué cardview-v7:27.1.1'!
implementation 'com.android.support:cardview-v7:27.1.1' 

When you add the implementation of the version 27.1.1 of this library in the build.gradle the main project, overwrite the definition of the modules or projects to avoid obsolete versions in dependencies and in this way solves the problem.

HolaDevs.com

HolaDevs is an online community of programmers and software lovers.
You can check other people responses or create a new question if you don't find a solution

Powered by:

X