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

806

更新到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

输入图像描述

我的Gradle:

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'
}

将以下代码添加到你的项目Build.Gradle中:subprojects { project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "26.+" } } } } - Sunil Chaudhary
54个回答

5

在升级至Android Studio 2.3后,我遇到了同样的问题。解决方法是在 build.gradle 文件中添加以下包:

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

注意:请将版本号改为你项目中使用的其他支持库包的版本号。


5
打开您项目的外部库,您会发现某些库仍在使用以前的版本,尽管您没有提到这些库。我的建议是只为特定的库版本使用它们,这将解决您的问题。

5

将错误部分标记并按下 "ALT+ENTER",你会看到一个选项:

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

这将带您进入一个菜单,在那里您将看到与 support-compat 不同的特定问题支持依赖项。在 gradle 中创建其依赖关系(com 'XXX'),并将其版本设置为与 support-compat 相匹配。同步 gradle,完成。


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"
}

5
implementation 'com.android.support:appcompat-v7:26.1.0'

在这行代码后,您需要在Gradle中添加新的一行:

implementation 'com.android.support:design:26.1.0'

你只需要第二个。它自己包含了第一个。 - OneCricketeer

4

我项目中有以下依赖项:

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'

implementation 'com.google.android.gms:play-services-maps:16.1.0'

implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'com.google.firebase:firebase-storage:17.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'

implementation 'com.firebaseui:firebase-ui-storage:0.6.0'

到目前为止看起来没有什么问题,但是我收到了这条消息:

发现版本28.0.0、23.4.0,例如 com.android.support:animated-vector-drawable:28.0.0和 com.android.support:palette-v7:23.4。

然后我执行了以下操作:

$ ./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath >> dep.txt

在文件中,我搜索了调色板,发现它被 Firebase 存储使用:
\--- com.firebaseui:firebase-ui-storage:0.6.0
     +--- com.android.support:appcompat-v7:23.4.0 -> 28.0.0 (*)
     +--- com.android.support:palette-v7:23.4.0

添加后:

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

看起来问题已经解决了,不再出现错误。

//干杯


4

替换这个

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

通过这个

compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:mediarouter-v7:25.3.1'

重构与良好编码


4

我在更新到Android Studio 2.3版本后遇到了这个问题。

添加以下依赖项可以解决我的问题。

compile 'com.android.support:customtabs:25.2.0'  
compile 'com.android.support:palette-v7:25.2.0'

3
我通过添加如下内容成功编译(代码不够整洁): image description here

3
问题可以通过以下方法解决:
  1. 打开您的AndroidManifest.xml文件。
  2. 在底部单击Merged Manifest选项
  3. 右侧将显示Other Manifest files。这里是不同依赖项的单独清单文件,这些依赖项被包含或由某些其他依赖项的影响所包含。
  4. 找到在您的错误消息中提到的依赖项。单击它以打开其清单文件。
  5. 如果您的错误消息说要更改meta-data中的android:value属性,则必须在此更改。
  6. 更改值和出现不匹配版本号的其他地方,并用您在build.gradle文件中包含的版本进行更改。
  7. 现在同步项目,您就可以开始使用了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接