当我放入“ play-services-ads”时,实现“ com.android.support:appcompat-v7:27.1.1”会出错

时间:2019-03-17 11:21:22

标签: android android-gradle admob

dependencies {
    implementation "org.jetbrains.anko:anko-commons:$anko_version"

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.android.support:appcompat-v7:27.1.1'
    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:espressocore:3.0.2'
}

这些是我的密码。


implementation 'com.google.android.gms:play-services-ads:17.1.1'

但是当我添加此AdMob代码时,

implementation 'com.android.support:appcompat-v7:27.1.1'

此代码导致错误:

All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:customtabs:26.1.0 less... (Ctrl+F1) 
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can

我该怎么办?

capture image

1 个答案:

答案 0 :(得分:1)

这可能是因为implementation 'com.google.android.gms:play-services-ads:17.1.1' 隐式使用了support libraries 26.1.0。您可以通过添加冲突库的确切版本来覆盖库。添加类似这样的内容:

implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:appcompat-v7:customtabs:27.1.1'