gms:play-services-ads:17.1.1报错所有com.google.android.gms库必须使用完全相同的版本规范

时间:2018-12-07 02:27:33

标签: android admob

所有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也会发生错误

我们如何解决这个问题

1 个答案:

答案 0 :(得分:0)

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

警告显示:

  

com.android.support:customtabs:xx.x.x

您需要实现:

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