简体   繁体   中英

Android appCompat dependency is throwing error

I m new to Android. Every time I include a dependency, I get the below error. I have tried a few possible solutions but nothing seems to work.

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:customtabs:27.0.2 less... (Ctrl+F1) Inspection info: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). Issue id: GradleCompatible`

First of all, assuming you're using pre androidx compat, pls make sure all your com.android.support dependencies are sharing exact same version. Here are example dependencies to search for (list is not full of course) :

com.android.support:appcompat-v7
com.android.support:support-annotations
com.android.support:design
com.android.support:cardview-v7
com.android.support:recyclerview-v7
com.android.support:gridlayout-v7
com.android.support:support-v4

Second, if all your compat dependencies are already sharing same version and issue only manifests when you're adding some other known dependency: you can exclude its transitive compat dependencies like this (build.gradle) :

implementation(...) {
    exclude module: 'appcompat-v7'
    exclude module: 'recyclerview-v7'
    exclude module: 'support-v4'
}

or like this:

implementation(...) {
    exclude group: 'com.android.support'
}

Third, if you don't know what kind of dependency is causing troubles - you can find it by reviewing tree generated by ./gradlew app:dependencies

The error was resolved by adding the dependencies specified in the error pop-up. Also the versions of the newly added dependency should be same as appcompat version: In my case the below code line of code resolved the issue: implementation 'com.android.support:support-v4:28.0.0' in the dependencies{}. I hope this helps. Thanks for the help:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM