在gradle中包含播放服务时,所有com.android.libraries支持都必须使用相同版本

时间:2018-06-25 19:14:07

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

我刚刚将广告添加到了我的应用程序中,作为该过程的一部分,我添加了

/*google play plugin for adMob*/
    compile 'com.google.android.gms:play-services:10.2.1'

作为我的gradle应用程序文件中的依赖项。但是我收到一个红色的下划线错误

compile 'com.android.support:appcompat-v7:26.+'

错误说: 所有com.android.libraries支持都必须使用相同的版本规范。混合可能导致崩溃。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "org.pctechtips.george.dailyquotes"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

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'
        /*firebase */
//        compile 'com.google.firebase:firebase-core:10.2.1'
    })
    //    compile 'com.android.support:appcompat-v7:21.0.3'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.android.support:support-v4:26.+'
    testCompile 'junit:junit:4.12'
    /*google play plugin for adMob*/
    compile 'com.google.android.gms:play-services:10.2.1'
}

1 个答案:

答案 0 :(得分:0)

play-services-ads:10.2.1依赖于play-services-basement:10.2.1,它依赖于createCommand()。这可能是不匹配的原因。

有关更多背景信息,请参见All com.android.support libraries must use the exact same version specification