Reputation: 1143
All my dependencies start from a verson 27, but the build task is still finishing with an Exception:
Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 25.4.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7:25.4.0 [GradleCompatible]
I know that I can add
lintOptions {
abortOnError false
}
and it will fix my issue, but I want to establish the reason.
Here is my build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 27
defaultConfig {
applicationId "my.company.app"
minSdkVersion 19
targetSdkVersion 27
multiDexEnabled true
versionCode 1
versionName "0.10.8"
vectorDrawables.useSupportLibrary = true
}
testOptions {
unitTests.returnDefaultValues = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://\"")
buildConfigField("String", "ENVIRONMENT", "\"release\"")
}
staging {
initWith debug
buildConfigField("String", "ENV_URL_PREFIX", "\"https://staging.\"")
buildConfigField("String", "ENVIRONMENT", "\"staging\"")
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "ENV_URL_PREFIX", "\"https://dev.\"")
buildConfigField("String", "ENVIRONMENT", "\"dev\"")
}
}
flavorDimensions "app"
productFlavors {
_Live {
dimension "app"
buildConfigField("String", "TYPE", "\"live\"")
}
_Test {
dimension "app"
buildConfigField("String", "TYPE", "\"test\"")
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
exclude 'lib/x86_64/darwin/libscrypt.dylib'
exclude 'lib/x86_64/freebsd/libscrypt.so'
exclude 'lib/x86_64/linux/libscrypt.so'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.9.1'
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
implementation 'me.dm7.barcodescanner:zxing:1.8.4'
implementation 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.zxing:zxing-parent:3.3.3'
implementation 'com.google.zxing:core:3.3.2'
implementation 'com.google.guava:guava:22.0'
implementation project(':mobile_api') // a module compiled with java plugin
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
}
My idea that some of the dependencies transit a com.android.support libraries with version 25.4.0. I would be grateful for any suggestions. Thanks in advance!
Upvotes: 1
Views: 164
Reputation: 1143
To fix it I added a dependency
implementation 'com.android.support:cardview-v7:27.1.1'
in my build.gradle which overrides 25.4.0. Therefore, you do not need to look for a dependency that includes a breaking library.
Upvotes: 0
Reputation: 4569
Add this to the very end of your root level build.gradle:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') { details.useVersion '27.x.x' }
}
}
Upvotes: 0
Reputation: 78
You are using this library 'com.crowdfire.cfalertdialog:cfalertdialog:1.1.0', and it in turn uses dependency 'com.android.support:cardview-v7:25.4.0' Perhaps this is the cause of the conflict.
Upvotes: 1