All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 15.0.0, 12.0.1. Examples include com.google.android.gms:play-services-ads:15.0.0 and com.google.android.gms:play-services:12.0.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).
android studio is giving me this error. How to solve this error? Here is the image of showing error.
You need to add a resolution strategy in your build.gradle file to tell which version of the library need to be used while building your application. The configuration might look something like this.
configurations.all {
resolutionStrategy {
force 'com.android.support:design:25.3.1'
force 'com.android.support:support-v4:25.3.1'
force 'com.android.support:appcompat-v7:25.3.1'
}
}
Modify as per your requirement of the library version.
As it says itself
Found versions 15.0.0, 12.0.1.
You should use same version for all google gms libraries.
Replace this line
compile 'com.google.android.gms:play-services:12.0.1'
with this
compile 'com.google.android.gms:play-services:15.0.0'
First of all use the whole play service is just wrong unless you really need every single sub-package, but from your screenshot you are already using some sub-package. The use of the whole play service package could means you need multi dex support because you include a lot of not needed methods, Proguard is your friend in this case. So my response is: just remove that line.
Related
No duplicate:
In my question I've already linked an answer similar to the supposed duplicate and explained, why I'm not looking for such an answer.
Android Studio 3.2.1 automatically included
implementation 'com.android.support:appcompat-v7:27.1.1'
for my new app. I manually included
implementation 'com.google.android.gms:play-services-ads:17.1.1'
following the official guide.
The official guide from google seems to be outdated, as Android Studio immediately suggests using version 17.1.3 instead.
In both cases however there is a red line under appcompat-v7 and a tooltip warning me that:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0.
I do get the general problem here, play-services-ads transitively depends on an old version of some support library. This answer suggests to simply include the offending libraries manually in the correct version.
However, I don't like this solution for two reasons:
I simply don't want to deal with problems like this. There should be compatible versions available for the google libraries.
At some point in the future I might have forgotten why I included all these libraries I don't even know what they do. I might want to update the appcompat and play-services-ads dependencies without thinking about all this again.
Is version 17.1.3 the most recent version of play-services-ads as of now? Does that mean that play-services-ads is generally lagging behind? If so, I would prefer to downgrade appcompat-v7 instead of including some library versions manually.
What would be the correct version of appcomat-v7 for play-services-ads version 17.1.3? Or maybe more generally asked: Which are the most recent versions of appcompat-v7 and play-services-ads that work together hassle free?
26.1.0 is the correct appcompat-v7 version for play-services-ads 17.1.*
implementation 'com.android.support:appcompat-v7:26.1.0'
This also requires compileSdkVersion and targetSdkVersion to be set to 26.
com.android.support:appcompat-v7:28.0.0-rc02
com.android.support:design:28.0.0-rc01 -> should be rc02, but there's no rc02 actually.
error:
app/build.gradle:74: 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-rc02, 28.0.0-rc01. Examples include com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01 [GradleCompatible]
I know it's a warning, we have turned to warn as the errors in CI in order to avoid the potential dead crashes, well, any solution except turn off option for CI?
issue
UPDATE
Design library version 28.0.0-cr02 published.
OLD ANSWER
According to this link
https://mvnrepository.com/artifact/com.android.support/design?repo=google
design:28.0.0-rc02 not yet published.
So all you can do for now is use the previous version for appcompat and wait until design library new version28.0.0-cr02 release.
So for now use this :
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
I don't know why... But they(sdk devs) behaving like Microsoft..
"Ohh..It compiles, lets ship it".
They just launch and don't care about bugs.. after updating to latest libs every time, first thing i get is..
"Layout editor preview errors.".
i hope it will be easy next time. :/
Keep track of the library here, until its published, use rc01 for other ones.
https://mvnrepository.com/artifact/com.android.support/design?repo=google
That's why I use stable versions always
If you are developing an app, you don't want to face these type of errors.
At the time of answering the current most stable version is 27.1.1 and second 28.0.0-rc02.
I suggest use 27.1.1 until 28 stable version release.
implementation 'com.android.support:appcompat-v7:27.1.1'
Sync again
No need of Invalidate/ Restart, Just restart would be okay. Or closing project and reopening from recent would be faster then restart.
Track the support library release.
Replace your
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
with
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
Looks like this should no longer be an issue. Looking at the link below, i think that whatever hiccups were encountered by OP are no longer relevant.
https://mvnrepository.com/artifact/com.android.support/appcompat-v7/28.0.0-rc02
About the error message "All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes)." The solution is outlined here (the answer by João Paulo Paiva).
To rid yourself of the error message, you have to basically include each package name mentioned in the warning - com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:cardview-v7:28.0.0-rc01
Essentially, manually add the following lines to your build.gradle
implementation com.android.support:animated-vector-drawable:28.0.0-rc02
implementation com.android.support:cardview-v7:28.0.0-rc02
You may encounter more such warnings - the solution is to keep subsequently adding the libraries/dependencies mentioned (and updating the version to 28.0.0-rc02 as well) until the warnings go away. I had this issue, and after the first lot, I didn't get any more, but YMMV!
1.Go to project/.idea/libraries folder on your file system and see which libraries are different.
2.You will have to manually include these libraries with the same version in your build.gradle file.
3.Then, sync your project
In Your Case:-
Add This Dependency :-
implements 'com.android.support:cardview-v7:28.0.0-rc02'
Add all dependency with Latest version which shows in error message.
I close this ticket, the problem has been solved that Google has updated design library to 28.0.0-rc02 .
I currently have a warning in my build.gradle about support libraries not using the same version.
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.1, 23.4.0. Examples include
com.android.support:animated-vector-drawable:27.0.1 and
com.android.support:cardview-v7:23.4.0
I do not actually include cardview-v7:23.4.0 and I'm trying to find out which library I'm using does.
What's the easiest way to see this?
And there is also a good way to see method counts of the libraries too?
Thanks.
You can plug in the dependency here and find out what dependencies the dependency has from the pom or read my post here its more better to call them transitive dependencies
Recently I wanted to update my app's dependencies, as I saw new version of com.android.support:appcompat-v7 library came up (27.0.0). After incrementing this lib version, Android Studio underlines this library and shows a popup with error message:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.0, 25.2.0. Examples include
com.android.support:animated-vector-drawable:27.0.0 and
com.android.support:support-v13:25.2.0
I've run gradlew app:dependencies command and saw other dependency which uses android support lib but it's older version - 25.2.0. My question is: what should I do? I assume I have to downgrade android support lib version as otherwise I may see No Method Found or No Class Found errors, am I right? Is it possible to include both of these versions somehow, that the library causing conflicts will be still able to use older version?
Thanks for help!
As you wrote already, one way is to downgrade to the lowest version. But I think that as long as you are not using that specific methods that the library with older dependency is using, you should be fine. But for the sake of safety, you should have all the dependecies of the same version
I have a jcenter library ToggleButtons I develop that I import into my app. After switching to support 26.1.0 in my app, I receive this error:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 26.1.0, 25.3.1
ToggleButtons:
com.android.support:cardview-v7:25.3.1
Main app:
com.android.support:design:26.1.0
I'm using other libraries such as Glide that reference even earlier versions of the support library (I haven't upgraded to 4 yet), but those don't have an issue. Have I designed the library improperly somehow?
This was always a recommendation, now they're making it generate errors.
You absolutely can't run an app with both versions, because that would cause duplicated classes errors. That means you must pick one of those manually now, while previously gradle would automatically choose one for you.
I'd suggest you use the higher number, since doing the opposite risks missing new features/assets that either library or app really depends on.
You can add this between your android and dependencies blocks in your application / library module's build.gradle for each conflict you must manually solve:
def supportLibraryVersion = '26.0.1'
configurations.all {
resolutionStrategy {
force "com.android.support:cardview-v7:$supportLibraryVersion"
}
}
I guess you get the idea of how it works.
Edit:
As noted by #eugen-pechanec the best practice is having all your support libraries with same version throughout all your projects modules. Also, it's best to use the same numbers on build tools (in module's build.gradle, inside android block).
Here's what your app depends on:
+ design:26.1.0
+ appcompat-v7:26.1.0
+ support-v4:26.1.0
+ recyclerview-v7:26.1.0
+ support-v4:26.1.0
Here's what the library depends on:
+ cardview-v7:25.3.1 (i.e. at least 25.3.1)
Here's what it means:
Card view library doesn't have any (runtime) dependency on other support libraries so technically in this case it's safe to use different versions. However this may change at any time.
More importantly your own code does not define cardview-v7 as a dependency so there's no way for gradle to know it should pull updated version as well.
The easiest fix then is just defining the dependency in your build.gradle:
def supportLibraryVersion = '26.0.1'
compile "com.android.support:cardview-v7:$supportLibraryVersion"
No force, nothing special. Upgrading a dependency is not a problem. Only downgrading is.
I still don't understand why Glide doesn't throw this error when they're using support 25.
As hinted above, Glide uses at least support-v4 25.x.x. And because a newer version of support-v4 is already requested by your own module, the dependency gets silently upgraded.