首页 > 解决方案 > android studio 中不兼容的 Gradle 版本

问题描述

我试图制作谷歌地图程序,它给出了那个错误

../../build.gradle: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). 

Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:26.1.0

有一些库或工具和库的组合不兼容,或者可能导致错误。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。注意:此问题在 Android Studio 和 IntelliJ IDEA 中有关联的快速修复操作。要抑制此错误,请使用问题 ID“GradleCompatible”,如抑制警告和错误部分中所述。

版本

dependencies {

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation'com.google.android.gms:play-services-maps:16.0.0'
    implementation 'com.google.android.gms:play-services-location:16.0.0'

}

标签: android

解决方案


您需要从esspresso-corecom.android.support中排除依赖项,如下所示:

androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

这将解决您的问题。


推荐阅读