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

Cha*_*kii 5 android build.gradle

将targetSdkVersion更新为27后,我收到此错误消息.

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

我知道我应该更新,com.android.support:support-media-compat但我不知道如何因为我没有在build.gradle中使用它,我试图更新SDK工具,但问题仍然存在.bellow是build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.ex"
        minSdkVersion 16
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    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'
    implementation 'com.google.android.gms:play-services-ads:11.6.2'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.bloder:magic:1.1'
    implementation 'com.android.support:recyclerview-v7:27.0.2'
    implementation 'com.android.support:cardview-v7:27.0.2'
}
Run Code Online (Sandbox Code Playgroud)

Cha*_*kii 6

我已经手动检查了项目中的库 - > .myidea->库,然后我发现我有两个使用旧版本的库:

com_android_support_support_media_compat_25_2_0 com_android_support_support_v4_25_2_0

然后只需在builde.gradle中添加此行

实现'com.android.support:support-v4:27.0.2'

错误现在消失了.