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
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.
After adding an firebase to your applicatio,I got this error message(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, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-rc02 and com.android.support:support-v4:26.1.0). and when i run my application it get crash.
enter image description here
The message is clear,you must use same exact same version specification, so check the build.gradle and update older version manually.
or you could click menu Analyze -- Run inspection by Name, and input "Newer Library Version Available" in search box. this will help you find newer library.
Please replace your build.gradle file with the following code
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
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.
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.