`android.support` cannot mix different versions - android

I have following dependencies in my android studio project.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.google.android.gms:play-services:11.8.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'
}
I just added com.google.android.gms:play-services and I can't figure out why the following error is occuring:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 25.2.0. ...
Does anyone know how to solve this problem. I assume it has got to do with the play services dependency using a different versions of android.support, or something similar, but can't find a single solution on the internet.
P.S I'm using kotlin if that makes any difference

Related

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0,

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:cardview-v7:27.0.
Whatever API I use gives me the same error.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
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'
The android team has been working on migrating the support libraries to androidx. This allows you to mix and match better.
Backup your project and in android studio go to
Refractor > Migrate to AndroidX
Add explicitly the library with the old version but with a new version number.
In your case implementation 'com.android.support:cardview-v7:28.0.0' so you need to add:
implementation 'com.android.support:cardview-v7:28.0.0'
ie: Take the library from the second item, and implement it with the version number from the first.
Note: don't forget to press sync now
Now after changes your dependencies will look like this:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation "com.android.support:support-media-compat:28.0.0"
implementation "com.android.support:customtabs:28.0.0"
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'
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'

dependencies error when add firebase libraries

When add firebase in
dependencies
implementation 'com.google.firebase:firebase-core:16.0.6'
Or
implementation 'com.google.firebase:firebase-ads:17.1.2'
Or
implementation 'com.google.android.gms:play-services-ads:17.1.1
It shows error under implementation 'com.android.support:appcompat-v7:28.0.0' that All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
When I sync the app no error but when install the app it shows you app has been stopped (Crashing during run time).
When remove the firebase dependencies and run, my app it's working fine.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.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.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
apply plugin: 'com.google.gms.google-services'
When you include dependencies, they too, will sometimes include dependencies of their own. Some of the firebase libraries happen to include support libraries at a lower version than 28. When you hover over the error message for appcompat-v7 it should tell you what library is lower than 28. You may have to click 'show more' on the error message. Once you figure out which one it is, include that exact same library but version 28. Resync your gradle and you're good to go. Also, you might have to do this multiple times because some firebase libraries include multiple lower version support libraries and the error message will only show you one library at a time.

Incompatible Gradle Versions in android studio [duplicate]

This question already has answers here:
All com.android.support libraries must use the exact same version specification
(54 answers)
Closed 4 years ago.
i was trying to make google map program and it gives that error
../../build.gradle: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0
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).
Note: This issue has an associated quickfix operation in Android Studio and IntelliJ IDEA.
To suppress this error, use the issue id "GradleCompatible" as explained in the Suppressing Warnings and Errors section.
the versions
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}
You need to exclude com.android.support dependency from esspresso-core like below:
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
This will fix your issue.
If you don't use Unit and Local testing then just remove these testing libraries. Your gradle will look like.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
}

libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha1, 26.1.0

ll com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 28.0.0-alpha1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:28.0.0-alpha1 and
com.android.support:customtabs:26.1.0 less... (Ctrl+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).
my gradle dependencies:-
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
warning on this dependencies -----------------------------
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
testImplementation 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-vision:15.0.2'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.3.+'
implementation 'com.memetix:microsoft-translator-java-api:0.6.2'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.facebook.android:audience-network-sdk:4.+'
>
Something's using older library and The culprit is firebase-core:16~;
After quite some trials I resolved this issue.
From this answere and this answer I solved the error.
You need to manually add dependencies that are conflicting. (To find conflicting dependencies an easy way is to hover over highlighted errors.)
You can either downgrade your appcompat library to the given/hinted one which is not recommended or manually declare those dependicies.
I Used this code with all updated libraries today and solved errors:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
//this thing is carusing error, to solve - see hints and manually add them.
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.android.support:support-media-compat:28.0.0-rc01'
implementation 'com.android.support:support-v4:28.0.0-rc01'
//implementation 'com.android.support:appcompat-v7:25.2.0'
/*implementation ("com.google.firebase:firebase-core:16.0.1"){
exclude group: 'com.android.support'
}
*/
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'
}
Such behavior makes new developers head scratch.
If this solves your problem please let others know too.
Happy coding.
Update.
Note: Don't forget to check if there's other libraries added to your project causing warning.
Proof of its working.
Use this dependencie
implementation 'com.android.support:appcompat-v7:27.1.1'
This is caused because your image cropper library contains older version of support library. Use this on your Image Cropper library:
implementation ("com.theartofdev.edmodo:android-image-cropper:2.3.+"){
exclude group: 'com.android.support'
}
This will remove your gradle issue .
Use this dependencies below
implementation 'com.android.support:support-v4:28.0.0'
implementation ("com.theartofdev.edmodo:android-image-cropper:2.3.+"){
exclude group: 'com.android.support'
}
nitinkumarp gives working advice. Perhaps the conflict has several dependencies. You need to check each one, remove all dependencies and add and synchronize one by one until a warning appears. This will be the dependency that causes the warning.

Android - appcompat-v7:27.1.1 error after adding facebook sdk

These are the dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
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:cardview-v7:27.1.1'
}
When I add implementation 'com.facebook.android:facebook-android-sdk:4.0.1' then it "breaks" implementation 'com.android.support:appcompat-v7:27.1.1' with the error: All com.android.support libraries must use the exact same version specification
Some answers from All com.android.support libraries must use the exact same version specification suggest that I have to look at all the libraries but I can't see what's wrong here:
Can someone explain it? I'm complete newbie in android and I must say it's a horrendous mess
Try use implementation 'com.facebook.android:facebook-android-sdk:4.35.0'

Categories

Resources