首页 > 解决方案 > gms:play-services-ads:17.1.1 给出错误所有 com.google.android.gms 库必须使用完全相同的版本规范

问题描述

所有 com.google.android.gms 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。

找到版本 17.1.2、16.0.5、16.0.4、16.0.1、16.0.0。示例包括 com.google.android.gms:play-services-ads-base:17.1.2 和 com.google.android.gms:play-services-measurement-base:16.0.5

这是我正在使用的 gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.hoper.friebasecrashalytics"
        minSdkVersion 14
        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'
    })
    compile 'com.android.support:appcompat-v7:26.0.2'
    compile "com.android.support:exifinterface:26.0.2"
    compile 'com.android.support:animated-vector-drawable:26.0.2'
    //compile 'com.google.firebase:firebase-core:16.0.5'
    compile  'com.google.android.gms:play-services-ads:17.1.1'
    //compile 'com.crashlytics.sdk.android:crashlytics:2.9.6'
    testCompile 'junit:junit:4.12'
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '26.0.2'
            }
        }
    }

}

apply plugin: 'com.google.gms.google-services'

即使我们不使用 firebase 也会发生错误

我们如何解决这个问题

标签: androidadmob

解决方案


检查警告中显示了哪些库,并使用相同的版本号实现它们。例如:

警告显示:

com.android.support:customtabs:xx.xx

你需要实现:

implementation 'com.android.support:customtabs:28.0.0'

推荐阅读