This question already has answers here:
All com.android.support libraries must use the exact same version specification
(54 answers)
Closed 5 years ago.
I have tried running my app using a specific activity, and I a continuous crash is taking place.
I have pinpointed an error that is to do with the appcompat version. However, I am unsure as to how to fix this error, i.e. get all my dependencies on the same version.
I was wondering if there is a quick fix to do this? And, if not, what are the steps to making sure that they are all on the correct/same version?
build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.benchalmers.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
This is the error that is being given to me:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.2, 26.1.0. Examples include
com.android.support:support-compat:27.0.2 and
com.android.support:animated-vector-drawable:26.1.0 less... (⌘F1)
There are some combinations of libraries, or tools and libraries, that
are incompatible, or can lead to bugs. One such incompatibility is
compiling with a version of the Android support libraries that is not
the latest version (or in particular, a version lower than your
targetSdkVersion.)
Any help would be much appreciated. Thanks.
Update your dependencies like so:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
Like the error message says: There's a conflicting version of Support Libraries found in your project. What you need to do to "fix" it is then make sure your Support Library version is the same (and preferably latest available).
In order to ease this process going forward, you could also make your code look like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def supportLibraryVersion = "27.0.2"
implementation "com.android.support:support-v4:$supportLibraryVersion"
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:support-v4:$supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile "com.android.support:cardview-v7:$supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
Also, as suggested by Michael Dodd, in order to use Support Library version 27.0.2, you'd need to bump your compileSdkVersion too:
android {
...
compileSdkVersion 27
...
}
Related
My compile is failing for some reason, but earlier it was working just fine.
This is the error I'm getting when trying to compile the project:
Program type already present: android.support.design.widget.CoordinatorLayout$Behavior
Message{kind=ERROR, text=Program type already present: android.support.design.widget.CoordinatorLayout$Behavior, sources=[Unknown source file], tool name=Optional.of(D8)}
(Build) app.iml :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "appjoe.wordpress.com.testdemo"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:26.1.0'
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'
implementation 'com.android.support:design:26.1.0'
// picasso and volley
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
// rxjava & rxandroid
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.16'
// glide
implementation 'com.github.bumptech.glide:glide:4.7.1'
// android views
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
}
I'm also getting an error for the second dependency in the dependencies area saying:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 27.1.0, 26.1.0. Examples include com.android.support:support-compat:27.1.1 and com.android.support:exifinterface:27.1.0 less... (Ctrl+1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
This is because of in the dependency some libraries(other than support libraries) has used supported libraries version different than yours that's why you are getting this error. you have mixed support libraries dependencies version 26 and 27.
So, you need to use a matching support library which is version 27.1.1. Change your build.gradle to something like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27 // use version 27
defaultConfig {
applicationId "appjoe.wordpress.com.testdemo"
minSdkVersion 23
targetSdkVersion 27 // targeting api version 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:27.1.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'
implementation 'com.android.support:design:27.1.1'
// picasso and volley
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'eu.the4thfloor.volley:com.android.volley:2015.05.28'
// retrofit
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
// rxjava & rxandroid
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation 'io.reactivex.rxjava2:rxjava:2.1.16'
// glide
implementation 'com.github.bumptech.glide:glide:4.7.1'
// android views
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
OR
Upgrade your libraries version to new version. Just hold cursor on each library. Android studio will tell you by Itself that this library has the new version available.
My depencies
dependencies {
compile 'me.dm7.barcodescanner:zxing:1.9'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
}
I get an error in appcompat line when compiling that found version 27.1.1,26.1.0 examples include ..vectordrawable 27.1.1 nd supportdesign 26.1.0
My target SDK is 26.
I tried to switch versions to 27 but my SDK target is 26, I get an error.
Whenever you see this type of problem, explicitly declare the probelmatic libraries in your gradle file with the same version of your other support libs:
implementation "com.android.support:animated-vector-drawable:26.1.0"
implementation "com.android.support:design:26.1.0"
implementation 'com.android.support:support-vector-drawable:26.1.0'
This happens because some of your dependencies use a different version of it.
Also, use implementation not compile. Compile has been deprecated:
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
There are conflicted dependencies in your project. You need to check up the dependencies tree of your project by running the following command in your Linux terminal:
./gradlew app:dependencies
or if you're using Windows:
gradlew app:dependencies
in your root project. Where app is your module name.
Quick checking your dependencies block, you will find the following library:
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
is using support library version 27.1.1 for its dependencies (You can check its build.gradle).
You can exclude the library from image cropper with:
implementation ('com.theartofdev.edmodo:android-image-cropper:2.7.0') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
The side effect of using the old version of support library is you can't be so sure that your program will work correctly. It's because the owner of library probably didn't test the library with older version of support library.
The better way is by changing your BuildToolsVersion, compileSdkVersion, targetSdkVersion, and support libraries to version 27. Something like the following:
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.package.name"
minSdkVersion 15
targetSdkVersion 27
...
}
...
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
// your other dependencies
...
}
I am having issues with gradle in my android application.
android {
compileSdkVersion 27
defaultConfig {
applicationId "za.co.gtsolutions.vivachoc"
minSdkVersion 15
targetSdkVersion 27
versionCode 2
versionName "1.5"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
implementation 'com.github.bumptech.glide:glide:4.6.1'
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.stripe:stripe-android:6.1.2'
implementation 'com.google.code.gson:gson:2.8.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
implementation 'testfairy:testfairy-android-sdk:1.+#aar'
testImplementation "org.robolectric:robolectric:3.8"
implementation 'com.facebook.android:facebook-login:4.32.0'
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support.test.espresso:espresso-contrib:3.0.1'
}
I get the following error: all com.android.support libraries should use the same version and my application will not run because of this. I have changed the minimumSDK Version and targetVersion to apply to the project that i am working on.
I am totaly lost on what the issue could be ?
use 27.0.2 instead of 27.1.1 like below
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
The answer after sometime is guided by the following answer: All com.android.support libraries must use the exact same version specification was the following:
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation "com.android.support:customtabs:27.1.1"
The application needs to use the customtabs library which was missing
I have a problem in gradle configuration, I get this error
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.1, 27.0.2. Examples include `com.android.support:animated-vector-drawable:28.0.0-alpha1` and `com.android.support:cardview-v7:27.1.1`
https://image.ibb.co/gwJ16n/Untitled.png "error"
How do I fix this problem?
Here is the complete buil.gradle configuration.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.sakan"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
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.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.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.github.linger1216:labelview:v1.1.1'
implementation 'com.github.ViksaaSkool:AwesomeSplash:v1.0.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.easing:library:1.0.1#aar'
implementation 'com.daimajia.androidanimations:library:1.1.3#aar'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-maps:15.0.0'
implementation 'com.google.android.gms:play-services-location:15.0.0'
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
implementation group:'com.squareup.picasso', name:'picasso', version:'2.5.0'
implementation 'com.github.chenupt.android:springindicator:1.0.2#aar'
implementation 'me.relex:circleindicator:1.2.2#aar'
implementation 'com.txusballesteros:bubbles:1.2.1'
implementation 'com.romainpiel.shimmer:library:1.4.0#aar'
implementation 'tyrantgit:explosionfield:1.0.1'
implementation 'com.github.ksoichiro:android-observablescrollview:1.5.0'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
implementation 'com.jakewharton:butterknife:7.0.1'
implementation 'com.mcxiaoke.volley:library-aar:1.0.0'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.github.darsh2:MultipleImageSelect:v0.0.4'
implementation 'com.facebook.android:facebook-android-sdk:4.32.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-appindexing:15.0.0'
implementation 'com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2'
implementation 'com.github.manuelpeinado.fadingactionbar:fadingactionbar-abc:3.1.2'
}
I think one of the dependencies is using a different target version, I don't know how to fix this problem.
Add this to the very end of your build.gradle (Module:app):
configurations.all {
resolutionStrategy.eachDependency { details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '27.1.1'
}
}
}
}
Make sure that you replace '27.1.1' with the version of the android support library that you want to use for all the dependencies , it should not be lower than your complile sdk version
than re sync gradle
I found this answer in : here
try to change config in build.gradle, as below
configurations.all {
resolutionStrategy {
force 'com.android.support:design:27.0.2'
force 'com.android.support:support-v4:27.0.2'
force 'com.android.support:appcompat-v7:27.0.2'
}
}
It makes forcefull changed to stated version, sometimes this is needed for signed apks
EDIT 1:
The error which is shown in image, won't bother builiding apk.
The error here is of aapt2.
By default aapt2 is enabled from gradle version 3.0+, you need to disable it by adding android.enableAapt2=false to gradle.properties file.
If it doesn't work, look for solution for aapt2 errors.
I have run build apk with above, by forcing support version as above, works fine for me, although error line didn't disappear
Change build.gradle to -> dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
}
After start using constraint layout my app does not build. It shows an error
This thing maybe fixed when I implement each library separately.
This error FOR now doesn't show but and not compile
Now dependencies like this
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:animated-vector-drawable:27.1.0'
implementation 'com.android.support:customtabs:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
I have done already Clean -> Rebuild also i tried to change libraries from that error manually but no results. Also after all that work with manual working i received new error
My OLD VERSION gradle file code below
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.borisruzanov.myapp"
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "auto"
// Enabling multidex support.
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//General
compile 'com.facebook.android:facebook-android-sdk:4.29.0'
//Firebase
compile 'com.google.firebase:firebase-core:11.8.0'
compile 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
compile 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.2.1'
implementation 'com.firebaseui:firebase-ui-database:3.2.1'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.firebase:firebase-config:11.8.0'
//Images
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'id.zelory:compressor:2.1.0'
//Network
compile 'com.squareup.okhttp:okhttp:2.7.5'
compile 'com.android.support:cardview-v7:27.1.0'
}
apply plugin: 'com.google.gms.google-services'
Figured out that Firebase using support library different version. How I can change it ?
I was facing this from two days and now I solved it today these are the steps
First Try this in your app level gradle file
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}`
if it does not solve try logging dependencies run this command
./gradlew -q dependencies app:dependencies --configuration compile
in your android studio's Terminal Tab it will log all the dependency tree of your project
then find which libraries are using duplicating dependencies
for example
implementation 'com.github.bumptech.glide:glide:4.6.1' is using duplicate dependencies
so change
implementation 'com.github.bumptech.glide:glide:4.6.1'
to
implementation('com.github.bumptech.glide:glide:4.6.1') {
exclude group: 'com.android.support'
}
Thats It..