appcompat-v7:27.1.1与play-services的冲突:11.0.1

时间:2018-05-28 11:20:13

标签: android gradle google-play-services android-support-library

我正在开发一款新应用。目前我正在尝试添加依赖。

implementation 'com.google.android.gms:play-services:11.0.1'

当我这样做时,我在实现' com.android.support上遇到了一个gradle编译错误:appcompat-v7:27.1.1'话说:

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

如何最好地解决此问题?

Gradle文件

apply plugin: 'com.android.application'

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

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    implementation 'com.android.support:mediarouter-v7:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    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:11.0.1'
}

1 个答案:

答案 0 :(得分:6)

问题是你在这个库中有一些暂时的依赖。每当发生这种情况时,您可以显式添加冲突的依赖项并将它们与当前版本匹配:

implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'