所有com.android.support库都必须使用完全相同的版本规范 [英] All com.android.support libraries must use the exact same version specification

查看:77
本文介绍了所有com.android.support库都必须使用完全相同的版本规范的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到android studio 2.3后,我收到此错误消息. 我知道这只是应用正常运行的提示,但确实很奇怪.

After updating to android studio 2.3 I got this error message. I know it's just a hint as the app run normally but it's really strange.

所有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

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 25.1.1, 24.0.0. Examples include com.android.support:animated-vector-drawable:25.1.1 and 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'
}

推荐答案

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

You can solve this with one of the following solutions:

从Android Studio 3.0开始,它变得更加容易,因为它现在显示了一个更有用的提示,因此我们只需要遵循此提示即可.
例如:

As of Android studio 3.0, it becomes much easier as it now shows a more helpful hint, so we only need to follow this hint.
for example:

所有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

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.0.2, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.0.2 and com.android.support:customtabs:26.1.0

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

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.)

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

Solution:
Add explicitly the library with the old version but with a new version number.
in my case com.android.support:customtabs:26.1.0 so I need to add:

implementation "com.android.support:customtabs:27.0.2"  

ie:从第二项中获取库,并从第一项中实现版本号.

ie: Take the library from the second item, and implement it with the version number from the first.

注意:请不要忘记立即按同步",以便gradle可以重建依赖关系图并查看是否还有更多冲突.

Note: don't forget to press sync now so gradle can rebuild the dependency graph and see if there are any more conflicts.

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

Explanation:
you may be confused by the error message as don't use customtabs so how I have a conflict!!
well.. you didn't use it directly but one of your libraries uses an old version of customtabs internally, so you need to ask for it directly.

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

if you curious to know which of your libraries is responsible for the old version and maybe ask the author to update his lib, Run a Gradle dependency report, see the old answer to know how.

请注意

灵感来自 CommonWare答案:

运行Gradle依赖性报告以查看您的完整树形结构 依赖是.

Run a Gradle dependency report to see what your full tree of dependencies is.

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

From there, you will see which one of your libraries are asking for a different version of the Android Support libraries. For whatever it is asking for, you can ask for it directly with the 25.2.0 version or use Gradle's other conflict resolution approaches to get the same versions.

从gradle插件版本开始:3.0 compile已由implementationapi取代,请参见此答案区别.

As of gradle plugin version: 3.0 compile has been replaced by implementation or api see this answer for the difference.

因此改为使用:

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

或对于Windows cmd:

or for windows cmd:

gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath

并搜索有冲突的版本.

对我来说,删除com.google.android.gms:play-services:10.2.0

并且仅包括com.google.android.gms:play-services-location:10.2.0com.google.android.gms:play-services-maps:10.2.0,因为它们是我使用的仅有的两个播放服务.

And only include com.google.android.gms:play-services-location:10.2.0 and com.google.android.gms:play-services-maps:10.2.0 as they are the only two play services that I use.

我认为gms:play-services依赖于支持库的某些旧组件,因此我们需要自己明确添加它们.

I think the gms:play-services depend on some old components of the support library, so we need to add them explicitly ourselves.

对于AS 3.0或更早的版本.

for AS 3.0 an older.

运行:

./gradlew -q dependencies <module-name>:dependencies --configuration implementation

示例:

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


如果有人对新的gradle插件了解更好的方法,请告诉我.


if someone knows a better way in the new gradle plugin please let me know.

这篇关于所有com.android.support库都必须使用完全相同的版本规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆