所有com.android.support库必须使用完全相同的版本规范

hum*_*zed 775 android build.gradle

更新到android studio 2.3后,我收到此错误消息.我知道这只是一个暗示,因为应用程序正常运行,但它真的很奇怪.

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到的版本25.1.1,24.0.0.示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

在此输入图像描述

我的朋友:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:support-v4:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.google.android.gms:play-services-maps:10.2.0'
    compile 'com.google.android.gms:play-services:10.2.0'

    compile 'io.reactivex.rxjava2:rxjava:2.0.1'
    compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
    compile 'com.jakewharton:butterknife:8.4.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
    compile 'com.blankj:utilcode:1.3.6'
    compile 'com.orhanobut:logger:1.15'
    compile 'com.facebook.stetho:stetho:1.4.2'

    provided 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.google.auto.value:auto-value:1.2'
    annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'

    compile 'com.mikepenz:iconics-core:2.8.2@aar'
    compile('com.mikepenz:materialdrawer:5.8.1@aar') { transitive = true }
    compile 'com.mikepenz:google-material-typeface:2.2.0.3.original@aar'
    compile 'me.zhanghai.android.materialprogressbar:library:1.3.0'
    compile 'com.github.GrenderG:Toasty:1.1.1'
    compile 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.8.0'
    compile 'com.github.MAXDeliveryNG:slideview:1.0.0'

    compile 'com.facebook.fresco:fresco:1.0.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'

    compile 'com.google.maps.android:android-maps-utils:0.4.4'
    compile 'com.github.jd-alexander:library:1.1.0'
}
Run Code Online (Sandbox Code Playgroud)

hum*_*zed 900

您可以使用以下解决方案之一解决此问题:

更新:

从Android studio 3.0开始,它变得更加容易,因为它现在显示了更有用的提示,所以我们只需要遵循这个提示.
例如: 1]

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).发现版本27.0.2,26.1.0.示例包括com.android.support:animated-vector-drawable:27.0.2和com.android.support:customtabs:26.1.0

有一些库,或工具和库的组合,它们是不兼容的,或者可能导致错误.一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)进行编译.

解决方案:
使用旧版本显式添加库,但使用新版本号.
在我的情况下,com.android.support:customtabs:26.1.0所以我需要添加:

implementation "com.android.support:customtabs:27.0.2"  
Run Code Online (Sandbox Code Playgroud)

即:从第二个项目中获取库,并使用第一个项目的版本号实现它.

注意:不要忘记现在按下同步,因此gradle可以重建依赖关系图并查看是否还有其他冲突.

说明:
您可能会对错误消息感到困惑,因为不要使用,customtabs所以我有冲突!
好吧..你没有直接使用它,但你的一个库在customtabs内部使用旧版本,所以你需要直接询问它.

如果您想知道哪些库负责旧版本并且可能要求作者更新他的lib,运行Gradle依赖性报告,请查看旧答案以了解具体方法.

请注意这一点


老答案:

灵感来自CommonsWare的答案:

运行Gradle依赖关系报告以查看完整的依赖关系树是什么.

从那里,您将看到哪个库要求提供不同版本的Android支持库.无论它要求什么,您可以直接使用25.2.0版本请求它,或使用Gradle的其他冲突解决方法来获得相同的版本.


更新:

从gradle插件版本开始:3.0 compile已被替换为implementationapi看到这个答案的差异.

因此使用:

./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
Run Code Online (Sandbox Code Playgroud)

或对于Windows cmd:

gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
Run Code Online (Sandbox Code Playgroud)

并搜索冲突的版本.

对我来说,删除后错误消失了 com.google.android.gms:play-services:10.2.0

并且只包括com.google.android.gms:play-services-location:10.2.0,com.google.android.gms:play-services-maps:10.2.0因为它们是我使用的唯一两种游戏服务.

我认为gms:play-services依赖于支持库的一些旧组件,所以我们需要自己添加它们.


适用于AS 3.0较旧的.

跑:

./gradlew -q dependencies <module-name>:dependencies --configuration implementation
Run Code Online (Sandbox Code Playgroud)

例:

./gradlew -q dependencies app:dependencies --configuration implementation
Run Code Online (Sandbox Code Playgroud)

如果有人在新的gradle插件中知道更好的方法,请告诉我.

  • `com.google.android.gms:play-services:10.2.0`支持SDK 14及更高版本,如果要在SDK 14下使用,则需要使用http:// stackoverflow中提到的版本`10.0.1`的.com /一个/六百二十四万八千四百九十一分之四千二百三十一万五千五百九 (3认同)
  • 指出错误消息中的"examples include"文本显示了您自己项目中的实际示例,而不是模糊问题类型的一般示例,这可能会有所帮助.从第二个项目中获取库,并使用第一个项目的版本号实现它. (3认同)
  • @humazed noob问题,我在哪里运行Android Studio中的命令? (2认同)

小智 203

  1. 转到project/.idea/libraries文件系统上的文件夹,查看哪些库不同.
  2. 您必须在文件中手动包含这些具有相同版本的库build.gradle.
  3. 然后,同步您的项目.

例如:

compile 'com.android.support:appcompat-v7:25.2.0'

// Wrong library version found on 1st point
compile 'com.android.support:customtabs:25.2.0'
Run Code Online (Sandbox Code Playgroud)

  • 在/ Project Files /我的项目/ .idea/libraries中有多个不同版本的支持文件.现在我怎么知道哪个模块或依赖项正在使用它? (10认同)
  • @SatpalYadav我搜索了与最新版本不匹配的版本(我在我的应用程序中使用).例如,我使用support:design:25.3.1但是材质对话框使用support-v13:25.1.1.所以我添加了支持-v13:25.3.1,错误消失了. (2认同)

Bra*_*dio 149

对于所有情况,不仅仅是这些版本或库:

注意一些关于错误的小信息窗口,它说明你必须改变和添加的例子.

在这种情况下:

找到的版本25.1.1,24.0.0.示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

您的

com.android.support:animated-vector-drawable:25.1.1

是版本25.1.1,和你的

com.android.support:mediarouter-v7:24.0.0

版本是24.0.0,因此您必须添加具有相同版本的mediarouter:

com.android.support:mediarouter-v7:25.1.1
Run Code Online (Sandbox Code Playgroud)

并为小信息窗口所示的每个示例执行此操作,在这种情况下, 所有库都没有版本25.1.1.

修复指定的库后,您必须同步gradle以查看您必须更改的下一个库和包.

重要:

如果您没有明确地使用一个或多个指定的库并且它给您错误,则意味着正在由另一个库在内部使用,无论如何都要显式编译它.

您还可以使用另一种方法来查看实际编译的所有库的版本差异(例如运行gradle依赖关系报告或转到库文件),真正的目标是编译您正在使用的所有库相同的版本.


小智 100

将它添加到build.gradle的最后(Module:app):

configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
    def requested = details.requested
    if (requested.group == 'com.android.support') {
        if (!requested.name.startsWith("multidex")) {
            details.useVersion '25.3.1'
        }
     }

   }
}
Run Code Online (Sandbox Code Playgroud)

确保将'25 .3.1'替换为要用于所有依赖项的android支持库的版本,它不应低于你的complile sdk版本

比重新同步gradle

  • 这为我节省了一天.但是这种机器人的开发每过一年就会变得更加分散.在推出之前,人们需要真正检查每个支持库.我们并不总是有足够的时间来完成每个新的支持版本,因为我们希望专注于构建我们的产品而不是完成所有这些.这总是令人沮丧 (4认同)
  • 这就是我所需要的,我的一个依赖关系以某种方式拉入27.0.1,即使我在顶层指定了较小的版本.出于好奇,你为什么要排除"多指数"? (3认同)

Ada*_*n P 96

解决这个问题的最好方法是实现android studio建议的所有'com.android.support:...'

(与您使用的支持版本无关 - 27.1.1,28.0.0等.)

将光标放在错误行上,例如:

implementation 'com.android.support:appcompat-v7:28.0.0'
Run Code Online (Sandbox Code Playgroud)

android studio会建议你'com.android.support:...'与'com.android.support:appcompat-v7:28.0.0'版本不同

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).发现版本28.0.0,27.1.0,27.0.2.示例包括com.android.support:animated-vector-drawable:28.0.0和com.android.support:exifinterface:27.1.0

所以添加com.android.support:animated-vector-drawable:28.0.0 & com.android.support:exifinterface:28.0.0.现在同步gradle文件.

逐个尝试实现所有建议的'com.android.support:...',直到此行没有错误 implementation 'com.android.support:appcompat-v7:28.0.0'

在我的情况下,我补充说

implementation 'com.android.support:appcompat-v7:28.0.0'

implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
Run Code Online (Sandbox Code Playgroud)

所有这些依赖关系......对其他人而言可能会有所不同.


Ber*_*vik 54

更新到Android Studio 2.3后,我遇到了完全相同的问题

将此行添加到依赖项解决了我的问题:

compile 'com.android.support:customtabs:25.2.0'
Run Code Online (Sandbox Code Playgroud)

  • 看起来我的问题也是因为renderscript,但是如果我需要renderscript的东西,而不是customtabs呢? (3认同)
  • 更新到Android Studio 2.3后,我遇到了完全相同的问题 (2认同)

Dan*_*son 45

A)运行gradle dependencies./gradlew dependencies

B)查看您的树并确定哪些依赖项为您无法控制的依赖项指定了不同的支持库版本.

我没有意识到如果依赖项完全由您自己的代码直接使用,也会显示此警告.在我的情况下,Facebook指定了一些我没有使用的支持库,你可以在下面看到大多数这些依赖项被我自己的25.2.0规范覆盖,用- > XXX(*)符号表示.卡片视图和自定义选项卡库没有被任何人覆盖,所以即使我不使用它们,我也需要自己要求25.2.0.

+--- com.facebook.android:facebook-android-sdk:4.17.0
|    +--- com.android.support:support-v4:25.0.0 -> 25.2.0 (*)
|    +--- com.android.support:appcompat-v7:25.0.0 -> 25.2.0 (*)
|    +--- com.android.support:cardview-v7:25.0.0
|    |    \--- com.android.support:support-annotations:25.0.0 -> 25.2.0
|    +--- com.android.support:customtabs:25.0.0
|    |    +--- com.android.support:support-compat:25.0.0 -> 25.2.0 (*)
|    |    \--- com.android.support:support-annotations:25.0.0 -> 25.2.0
|    \--- com.parse.bolts:bolts-android:1.4.0 (*)
Run Code Online (Sandbox Code Playgroud)

如果gradle已经警告过你并给你举例......

示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

...如果你为较低版本引入一些grep突出显示更容易,因为gradle dependencies它可能非常详细:

./gradlew dependencies | grep --color -E 'com.android.support:mediarouter-v7|$'
Run Code Online (Sandbox Code Playgroud)


Dan*_*l F 31

使用变量:执行以下操作将使您更容易确保对所有库使用相同的版本

dependencies {

    ext {
        support_library_version = '25.2.0'
        google_play_services_version = '10.2.0'
    }

    //#####################################################################
    //          Support Library
    //#####################################################################
    compile "com.android.support:appcompat-v7:${support_library_version}"
    compile "com.android.support:palette-v7:${support_library_version}"
    compile "com.android.support:design:${support_library_version}"

    //#####################################################################
    //          Google Play Services
    //#####################################################################
    compile "com.google.android.gms:play-services-auth:${google_play_services_version}"
    compile "com.google.android.gms:play-services-ads:${google_play_services_version}"
    compile "com.google.android.gms:play-services-analytics:${google_play_services_version}"

    //#####################################################################
    //          Firebase
    //#####################################################################
    compile "com.google.firebase:firebase-core:${google_play_services_version}"
    compile "com.google.firebase:firebase-auth:${google_play_services_version}"
    compile "com.google.firebase:firebase-messaging:${google_play_services_version}"
Run Code Online (Sandbox Code Playgroud)

有关Google如何建议您处理此版本控制的更多信息,请参阅以下文章:https://developer.android.com/studio/build/index.html#top-level

  • 只有一个注意事项:正如上面链接中所建议的,我们应该再次在TOP LEVEL GRADLE FILE中定义这个类型的变量) (2认同)

Moh*_*ari 25

我只想补充一点:

compile 'com.android.support:mediarouter-v7:25.2.0'
Run Code Online (Sandbox Code Playgroud)

Updated 适用于新的SDK版本

compile 'com.android.support:mediarouter-v7:28.0.0-alpha3'
Run Code Online (Sandbox Code Playgroud)


Pra*_*abs 19

如果出现相同的错误 appcompat

implementation 'com.android.support:appcompat-v7:27.0.1'
Run Code Online (Sandbox Code Playgroud)

然后加入design解决了它.

implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support:design:27.0.1'
Run Code Online (Sandbox Code Playgroud)

对我来说,补充一下

implementation 'de.mrmaffen:vlc-android-sdk:2.0.6'
Run Code Online (Sandbox Code Playgroud)

被包括appcompat-v7:23.1.1

.idea /库

没有vlc,appcompat单独就足够了.


ano*_*an2 19

正如您已经看到上面的所有答案和评论,但这个答案是为了清除新开发人员可能无法轻易获得的内容.

./gradlew -q dependencies app:dependencies --configuration compile

上面这行将毫无疑问地挽救你的生命,但是如何从上面的结果中得到确切的观点.

当您从上面的命令获得所有依赖关系图表或列表时,您必须搜索您在代码中获得的冲突版本号.请看下面的图片.

在此输入图像描述

在上面的图像中,您可以看到23.4.0正在创建问题但我们无法在gradle文件中找到它.所以现在这个版本号(23.4.0)将节省我们.当我们有这个数字时,我们会在上面的命令结果的结果中找到这个数字,并直接在我们的gradle文件中直接导入该依赖项.请参阅下图以获得清晰的视图.

你可以清楚地看到com.android.support:cardview-v7:23.4.0com.android.support:customtabs:23.4.0正在使用创建问题的版本.现在只需从依赖列表中复制这些行,并在我们的gradle文件中显式使用,但使用更新的版本链接

实现"com.android.support:cardview-v7:26.1.0"实现"com.android.support:customtabs:26.1.0"


Gai*_*der 15

解决冲突的另一种方法是强制所有依赖项的正确版本,如下所示:

dependencies {
            configurations.all {
                resolutionStrategy.eachDependency { DependencyResolveDetails details ->
                    if (details.requested.group == 'com.android.support' && details.requested.name == 'support-v4') {
                        details.useVersion "27.0.2"
                    }
                }
    ...
    }
Run Code Online (Sandbox Code Playgroud)

https://docs.gradle.org/current/userguide/customizing_dependency_resolution_behavior.html


Meh*_*ğlu 12

使用support-v13而不是support-v4

compile 'com.android.support:support-v13:25.2.0'
Run Code Online (Sandbox Code Playgroud)


小智 12

在应用程序级别依赖项中添加这些

implementation 'com.android.support:asynclayoutinflater:28.0.0'
implementation 'com.android.support:exifinterface: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:support-v4:28.0.0'
Run Code Online (Sandbox Code Playgroud)


小智 9

我的问题与你的问题类似.这里存在错误!

compile 'com.android.support:appcompat-v7:25.3.0'

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).发现版本25.3.0,24.0.0.示例包括'com.android.support:animated-vector-drawable:25.3.0'和'com.android.support:mediarouter-v7:24.0.0'

看到这个例子包括'com.android.support:animated-vector-drawable:25.3.0'和'com.android.support:mediarouter-v7:24.0.0'

只需在依赖项中添加这些代码,确保版本相同.

compile 'com.android.support:animated-vector-drawable:25.3.0'
compile 'com.android.support:mediarouter-v7:25.3.0'
Run Code Online (Sandbox Code Playgroud)


sa_*_*uin 9

添加compile 'com.google.android.gms:play-services:10.2.4'编译后我得到了同样的错误'com.android.support:appcompat-v7:25.3.1'.

添加animated-vector-drawablemediarouter libs修复问题.

compile 'com.google.android.gms:play-services:10.2.4'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:animated-vector-drawable:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'
Run Code Online (Sandbox Code Playgroud)


Sag*_*tel 9

我有这个:

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:27.1.1'
   implementation 'com.android.support:design:27.1.1'
   implementation 'com.android.support:support-v4:27.1.1'
   implementation 'com.google.firebase:firebase-auth:12.0.1'
   implementation 'com.google.firebase:firebase-firestore:12.0.1'
   implementation 'com.google.firebase:firebase-messaging:12.0.1'
   implementation 'com.google.android.gms:play-services-auth:12.0.1'
   implementation'com.facebook.android:facebook-login:[4,5)'
   implementation 'com.twitter.sdk.android:twitter:3.1.1'
   implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
   implementation 'org.jetbrains:annotations-java5:15.0'
   implementation project(':vehiclesapi')
   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'
}
Run Code Online (Sandbox Code Playgroud)

并得到此错误: 在此输入图像描述

解决方案很简单 - 主要的依赖关系都是正确的,所以叶子 - 任何第三方依赖.一个接一个地删除,直到找到罪魁祸首,结果是facebook!它使用Android支持库的27.0.2版本.我试图添加cardview版本27.1.1,但是这个解决方案仍然不够简单.

dependencies {
   implementation fileTree(dir: 'libs', include: ['*.jar'])
   implementation 'com.android.support:appcompat-v7:27.1.1'
   implementation 'com.android.support:design:27.1.1'
   implementation 'com.android.support:support-v4:27.1.1'
   implementation 'com.google.firebase:firebase-auth:12.0.1'
   implementation 'com.google.firebase:firebase-firestore:12.0.1'
   implementation 'com.google.firebase:firebase-messaging:12.0.1'
   implementation 'com.google.android.gms:play-services-auth:12.0.1'
   implementation('com.facebook.android:facebook-login:[4,5)'){
       // contains com.android.support:v7:27.0.2, included required com.android.support.*:27.1.1 modules
    exclude group: 'com.android.support'
   }
   implementation 'com.android.support:cardview-v7:27.1.1' // to replace facebook sdk's cardview-v7:27.0.2.
   implementation 'com.twitter.sdk.android:twitter:3.1.1'
   implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
   implementation 'org.jetbrains:annotations-java5:15.0'
   implementation project(':vehiclesapi')
   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'
}
Run Code Online (Sandbox Code Playgroud)


Apa*_*nha 8

升级到android studio 2.3之后我用这两个来解决我的问题

compile 'com.android.support:animated-vector-drawable:25.0.0'
compile 'com.android.support:mediarouter-v7:25.0.0'
Run Code Online (Sandbox Code Playgroud)


Hes*_*rsy 8

之前我遇到了同样的问题,我得到了解决方案.

我刚刚添加了具有另一个版本但具有相同版本的库的库support:appcompat.

例如,您的错误:

所有com.android.support库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃).找到的版本25.1.1,24.0.0.示例包括com.android.support:animated-vector-drawable:25.1.1和com.android.support:mediarouter-v7:24.0.0

*解决方案是编译这些库的版本:

compile 'com.android.support:mediarouter-v7:25.1.1'

- 如果另一个库有相同的问题,并有另一个版本只是用你的support:appcompat版本编译它

这解决了我的问题,我希望它可以解决你的问题.

最好的祝愿 :)


Ali*_*aca 8

搜索和组合答案后,这个问题的2018版本对我有用:

1)在导航选项卡上将其更改为项目视图

2)导航到[YourProjectName] /.idea/libraries /

3)删除以Gradle__com_android_support_ [libraryName]开头的所有文件

例如:Gradle__com_android_support_animated_vector_drawable_26_0_0.xml

4)在gradle文件中定义一个变量并用它来替换版本号,如$ {variableName}

Def变量:

ext {
    support_library_version = '28.0.0' //use the version of choice
}
Run Code Online (Sandbox Code Playgroud)

使用变量:

implementation "com.android.support:cardview-v7:${support_library_version}"
Run Code Online (Sandbox Code Playgroud)

示例gradle:

dependencies {
    ext {
        support_library_version = '28.0.0' //use the version of choice
    }

    implementation fileTree(include: ['*.jar'], dir: 'libs')

    implementation "com.android.support:animated-vector-drawable:${support_library_version}"
    implementation "com.android.support:appcompat-v7:${support_library_version}"
    implementation "com.android.support:customtabs:${support_library_version}"
    implementation "com.android.support:cardview-v7:${support_library_version}"
    implementation "com.android.support:support-compat:${support_library_version}"
    implementation "com.android.support:support-v4:${support_library_version}"
    implementation "com.android.support:support-core-utils:${support_library_version}"
    implementation "com.android.support:support-core-ui:${support_library_version}"
    implementation "com.android.support:support-fragment:${support_library_version}"
    implementation "com.android.support:support-media-compat:${support_library_version}"
    implementation "com.android.support:appcompat-v7:${support_library_version}"
    implementation "com.android.support:recyclerview-v7:${support_library_version}"
    implementation "com.android.support:design:${support_library_version}"

}
Run Code Online (Sandbox Code Playgroud)


小智 7

在2018年更新此错误从项目结构添加实现

implementation 'com.android.support:support-v13:28.0.0'
Run Code Online (Sandbox Code Playgroud)

在项目模式 - > 外部库你可以找到你的问题,在我的情况下,我使用的是版本28和我发现的外部库 com.android.support:support-media-compat-26.0.0,这里是错误.

实施后support v13,它的工作


Sha*_*aon 7

在升级到android studio 3.4和sdk版本到28.0.0之后,我已经遇到了这个问题。应用以下依赖项为我解决了这个问题。

    implementation 'com.android.support:exifinterface:28.0.0'
Run Code Online (Sandbox Code Playgroud)


Sne*_*dya 6

您已定义任何其他依赖项以使用版本24.0.0而不是25.1.1.请将所有依赖项版本设置为相同25.1.1.


Shr*_*ant 6

我必须在gradle中添加以下行以删除错误

compile 'com.android.support:animated-vector-drawable:25.2.0'
compile 'com.android.support:preference-v7:25.2.0'
compile 'com.android.support:customtabs:25.2.0'
compile 'com.android.support:cardview-v7:25.2.0'
Run Code Online (Sandbox Code Playgroud)


Mat*_*t W 6

我运行了./gradlew tasks --all并检查了与目标版本(25.3.1)不同版本的依赖项.你会得到这样的东西:

app:prepareComAndroidSupportAnimatedVectorDrawable2531Library - Prepare com.android.support:animated-vector-drawable:25.3.1
app:prepareComAndroidSupportAppcompatV72531Library - Prepare com.android.support:appcompat-v7:25.3.1
app:prepareComAndroidSupportCardviewV72531Library - Prepare com.android.support:cardview-v7:25.3.1
app:prepareComAndroidSupportCustomtabs2531Library - Prepare com.android.support:customtabs:25.3.1
app:prepareComAndroidSupportDesign2531Library - Prepare com.android.support:design:25.3.1
app:prepareComAndroidSupportMediarouterV72531Library - Prepare com.android.support:mediarouter-v7:25.3.1
app:prepareComAndroidSupportPaletteV72531Library - Prepare com.android.support:palette-v7:25.3.1
app:prepareComAndroidSupportRecyclerviewV72531Library - Prepare com.android.support:recyclerview-v7:25.3.1
app:prepareComAndroidSupportSupportCompat2531Library - Prepare com.android.support:support-compat:25.3.1
app:prepareComAndroidSupportSupportCoreUi2531Library - Prepare com.android.support:support-core-ui:25.3.1
app:prepareComAndroidSupportSupportCoreUtils2531Library - Prepare com.android.support:support-core-utils:25.3.1
app:prepareComAndroidSupportSupportFragment2531Library - Prepare com.android.support:support-fragment:25.3.1
app:prepareComAndroidSupportSupportMediaCompat2531Library - Prepare com.android.support:support-media-compat:25.3.1
app:prepareComAndroidSupportSupportV42531Library - Prepare com.android.support:support-v4:25.3.1
app:prepareComAndroidSupportSupportVectorDrawable2531Library - Prepare com.android.support:support-vector-drawable:25.3.1
app:prepareComAndroidSupportTransition2531Library - Prepare com.android.support:transition:25.3.1
app:prepareComAndroidVolleyVolley100Library - Prepare com.android.volley:volley:1.0.0
app:prepareComCrashlyticsSdkAndroidAnswers1312Library - Prepare com.crashlytics.sdk.android:answers:1.3.12
app:prepareComCrashlyticsSdkAndroidBeta124Library - Prepare com.crashlytics.sdk.android:beta:1.2.4
app:prepareComCrashlyticsSdkAndroidCrashlytics267Library - Prepare com.crashlytics.sdk.android:crashlytics:2.6.7
app:prepareComCrashlyticsSdkAndroidCrashlyticsCore2316Library - Prepare com.crashlytics.sdk.android:crashlytics-core:2.3.16
app:prepareComFacebookAndroidFacebookAndroidSdk4161Library - Prepare com.facebook.android:facebook-android-sdk:4.16.1
app:prepareComGoogleAndroidGmsPlayServicesAnalytics1026Library - Prepare com.google.android.gms:play-services-analytics:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesAnalyticsImpl1026Library - Prepare com.google.android.gms:play-services-analytics-impl:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesAuth1026Library - Prepare com.google.android.gms:play-services-auth:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesAuthBase1026Library - Prepare com.google.android.gms:play-services-auth-base:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesBase1026Library - Prepare com.google.android.gms:play-services-base:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesBasement1026Library - Prepare com.google.android.gms:play-services-basement:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesCast1026Library - Prepare com.google.android.gms:play-services-cast:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesLocation1026Library - Prepare com.google.android.gms:play-services-location:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesMaps1026Library - Prepare com.google.android.gms:play-services-maps:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesTagmanagerV4Impl1026Library - Prepare com.google.android.gms:play-services-tagmanager-v4-impl:10.2.6
app:prepareComGoogleAndroidGmsPlayServicesTasks1026Library - Prepare com.google.android.gms:play-services-tasks:10.2.6
app:prepareComGoogleFirebaseFirebaseAnalytics1026Library - Prepare com.google.firebase:firebase-analytics:10.2.6
app:prepareComGoogleFirebaseFirebaseAnalyticsImpl1026Library - Prepare com.google.firebase:firebase-analytics-impl:10.2.6
app:prepareComGoogleFirebaseFirebaseAppindexing1024Library - Prepare com.google.firebase:firebase-appindexing:10.2.4
app:prepareComGoogleFirebaseFirebaseCommon1026Library - Prepare com.google.firebase:firebase-common:10.2.6
app:prepareComGoogleFirebaseFirebaseCore1026Library - Prepare com.google.firebase:firebase-core:10.2.6
app:prepareComGoogleFirebaseFirebaseIid1026Library - Prepare com.google.firebase:firebase-iid:10.2.6
app:prepareComGoogleFirebaseFirebaseMessaging1026Library - Prepare com.google.firebase:firebase-messaging:10.2.6
app:prepareComMindorksPlaceholderview027Library - Prepare com.mindorks:placeholderview:0.2.7
app:prepareDebugAndroidTestDependencies
app:prepareDebugDependencies
app:prepareDebugUnitTestDependencies
app:prepareInfoHoang8fAndroidSegmented105Library - Prepare info.hoang8f:android-segmented:1.0.5
app:prepareIoFabricSdkAndroidFabric1316Library - Prepare io.fabric.sdk.android:fabric:1.3.16
app:prepareNoNordicsemiAndroidLog211Library - Prepare no.nordicsemi.android:log:2.1.1
app:prepareNoNordicsemiAndroidSupportV18Scanner100Library - Prepare no.nordicsemi.android.support.v18:scanner:1.0.0
Run Code Online (Sandbox Code Playgroud)

在这种情况下,我的目标是25.3.1,并且在运行此命令时有一些针对不同版本的依赖项.诀窍是识别此列表中针对先前版本的依赖项,并通过在Gradle中导入最新版本的依赖项来覆盖该依赖项.


Pha*_*inh 6

这是我修复此警告的流程

的build.gradle

android {
    compileSdkVersion ... // must same version (ex: 26)
    ...
}

dependencies {
    ...
    compile 'any com.android.support... library'  // must same version (ex: 26.0.1)
    compile 'any com.android.support... library'  // must same version (ex: 26.0.1)

    ...
    compile ('a library B which don't use 'com.android.support...' OR use SAME version of 'com.android.support'){
         // do nothing 
    }

    ...
    compile ('a library C which use DIFFERENT 'com.android.support...' (ex:27.0.1) { 
        // By default, if use don't do anything here your app will choose the higher com.android.support... for whole project (in this case it is 27.0.1)

        // If you want to use 26.0.1 use
        exclude group: 'com.android.support', module: '...' (ex module: 'appcompat-v7') 
        exclude group: 'com.android.support', module: 'another module'
        ...

        // If you want to use 27.0.1 do 
        Upgrade `compileSdkVersion` and all 'com.android.support' to 27.0.1.
        (It may be a good solution because the best practice is always use latest `compileSdkVersion`.  
        However, use 26 or 27 is base on you for example higher library may have bug)
    }
}
Run Code Online (Sandbox Code Playgroud)

查看/验证应用中dependencies的所有库,请
打开终端并运行./gradlew app:dependencies

dependencies在应用程序中查看特定库,请按照以下教程进行操作: - 如何在Gradle中排除特定依赖项的依赖项

希望它有所帮助


Ham*_*man 6

我有同样的问题,但我通过添加这三行来解决这个问题

implementation 'com.android.support:design:27.1.1'
implementation "com.android.support:customtabs:27.1.1"
implementation 'com.android.support:mediarouter-v7:27.1.1'
Run Code Online (Sandbox Code Playgroud)

现在每件事都很完美


Muh*_*mad 6

新版本的android studio 3.x非常简单。

只需复制小于当前版本的版本,然后使用与当前版本相同的版本号显式添加即可。

找到版本27.1.1、27.1.0。示例包括com.android.support:animated-vector-drawable:27.1.1和com.android.support:exifinterface:27.1.0

只需复制该版本com.android.support:exifinterface:27.1.0并将其更改com.android.support:exifinterface:27.1.1为与当前使用的版本相同,然后将其添加到gradle依赖项中,如下所示。

implementation 'com.android.support:exifinterface:27.1.1'
Run Code Online (Sandbox Code Playgroud)

注意:完成操作后,请不要忘记单击编辑器顶部的立即同步


Sub*_*bho 5

打开项目的外部库,你会看到一些库仍然使用以前的版本,虽然你没有提到那些库所以我的建议只是使用特定的库版本来解决你的问题.


小智 5

我只是将我的Android支持存储库更新为(版本:44.0.0); 然后Android SDK工具和模拟器从sdk管理器> SDK工具到最新版本25.3.1它解决了我的问题.


Oct*_*cat 5

对我来说,错误是我导入的第三方库导致使用较旧的Google支持库模块的结果.我只是将它们更新到最新版本(例如检查Github),错误消失了.我建议您检查您所包含的所有非Google图书馆是build.gradle最新的.


Vah*_*iri 5

更新到Android Studio 2.3后出现同样的问题,修复方法是在以下位置添加以下包build.gradle:

compile 'com.android.support:support-v13:25.3.1'

注意:更改版本以匹配项目中使用的其他支持库包


JP *_*ura 5

确保所有Facebook SDK依赖项都使用项目的相同支持库版本:

dependencies {
    // Facebook SDK dependencies, excluding Bolts
    compile "com.android.support:appcompat-v7:25.4.0"
    compile "com.android.support:cardview-v7:25.4.0"
    compile "com.android.support:customtabs:25.4.0"
    compile "com.android.support:design:25.4.0"

    compile "com.facebook.android:facebook-android-sdk:4.23.0"
}
Run Code Online (Sandbox Code Playgroud)


Ray*_*aga 5

突出显示错误并按"ALT + ENTER",您将看到一个选项:

添加库依赖关系>编辑意图设置

这将带您进入一个菜单,您将看到与support-compat不同的特定问题支持依赖项.在gradle(com'XXX')中创建它的依赖项并设置它的版本以匹配support-compat的版本.同步gradle,你就完成了.


小智 5

implementation 'com.android.support:appcompat-v7:26.1.0'
Run Code Online (Sandbox Code Playgroud)

在此行之后您必须在您的gradle中添加新行

implementation 'com.android.support:design:26.1.0'
Run Code Online (Sandbox Code Playgroud)