1

当我尝试使用基于 minSdk 的风格编译我的应用程序时,我收到一个错误:

错误:任务“:app:processCurrentDebugGoogleServices”执行失败。

请通过更新 google-services 插件的版本来修复版本冲突(有关最新版本的信息可在 https://bintray.com/android/android-tools/com.google.gms.google-services/获得)或将 com.google.android.gms 的版本更新为 10.2.0。

我粘贴了Android 开发者博客中的示例,但它不起作用。

项目等级:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.0'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用等级:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '25.0.2'
    defaultConfig {
        applicationId 'pl.net.szafraniec.testApp'
        minSdkVersion 10
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        legacy {
            minSdkVersion 9
            versionCode 901  // Min API level 9, v01
        }
        current {
            minSdkVersion 14
            versionCode 1401  // Min API level 14, v01
        }
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    legacyCompile 'com.google.android.gms:play-services:10.0.0'
    currentCompile 'com.google.android.gms:play-services:10.2.0'
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile 'com.android.support:design:25.2.0'
    testCompile 'junit:junit:4.12'
    compile 'com.f2prateek.ln:ln:1.1.1'
}
apply plugin: 'com.google.gms.google-services'
4

1 回答 1

0

此问题的一种解决方法是将apply plugin: 'com.google.gms.google-services'行放在您的依赖项块下方,允许插件确定您正在使用的 Play 服务版本。既然您已经这样做了,请尝试下载Google Support Repository. 您可以在Tools -> Android-> SDK Manager->中找到它SDK Tools

您还可以查看此相关 SO 帖子中的答案:Google Play Services GCM 9.2.0 asks to "update" back to 9.0.0

于 2017-03-10T09:20:12.417 回答