I just updated one of my projects by changing the dependencies to new versions, but now I have a problem telling me that the build failed and showing me the following error message on the Build screen:
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 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'
Note that the library AndRoboDroid
( implementation project(':AndRoboDroid')
) referenced in the build.gradle
main file has also been 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 above configuration:
- Make sure the whole project does not have versions
27.0.2
as indicated by the error. - I restarted the IDE.
- Clean the project, even delete the contents of the directories
/build
Actually the problem is that the project was using
CardViews
and the library had definitions with version 27.0.2 but it did not find them when I did a search since they were inside.JAR
Inside the main project in my file
build.gradle
I also added the library definitioncardview
:By adding the implementation of the version
27.1.1
of this library in thebuild.gradle
main project, it overwrites the definition of the modules or projects to avoid obsolete versions in the dependencies and in this way the problem is solved.