无法使用Gradle和flavor和com.google.gms.google-services插件构建应用程序 [英] Cannot build app with Gradle with flavors and com.google.gms.google-services plugin

查看:224
本文介绍了无法使用Gradle和flavor和com.google.gms.google-services插件构建应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b


错误:任务$ b的执行失败

当我尝试使用基于minSdk的口味编译我的应用程序时, $ b':app:processCurrentDebugGoogleServices'。


请通过更新google-services插件的版本来修复版本冲突最新版本是
,可在
https://bintray.com/android/android-tools/com.google.gms.google-services/
或将com.google.android.gms的版本更新至10.2.0 。



我粘贴了 Android Developers Blog 它不起作用。



proj ect gradle:

  //顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。 
$ b buildscript {
repositories {
jcenter()
}
依赖关系{
classpath'com.android.tools.build:gradle: 2.3.0'
classpath'com.google.gms:google-services:3.0.0'
//注意:不要在这里放置您的应用程序依赖关系;它们属于单个模块build.gradle文件中的
//
}
}

allprojects {
存储库{
jcenter()



任务清理(类型:删除){
删除rootProject.buildDir
}

app gradle:

  apply plugin:'com。 android.application'

android {
compileSdkVersion 25
buildToolsVersion '25 .0.2'
defaultConfig {
applicationId'pl.net.szafraniec.testApp'
minSdkVersion 10
targetSdkVersion 25
versionCode 1
versionName1.0
testInstrumentationRunnerandroid.support.test.runner.AndroidJUnitRunner
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
} $ b $基点roductFlavors {
legacy {
minSdkVersion 9
versionCode 901 // Min API level 9,v01
}
current {
minSdkVersion 14
versionCode 1401 //最小API级别14,v01
}
}
}

依赖关系{
编译fileTree(包括:['* .jar'] ,dir:'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2',{
exclude group:'com.android.support',module :'support-annotations'
})
legacyCompile'c​​om.google.android.gms:play-services:10.0.0'
currentCompile'c​​om.google.android.gms:play- services:10.2.0'
compile'c​​om.android.support:appcompat-v7:25.2.0'
compile'c​​om.android.support:design:25.2.0'
testCompile' junit:junit:4.12'
compile'c​​om.f2prateek.ln:ln:1.1.1'
}
apply plugin:'com.google.gms.google-services


解决方案

变通办法对于这个问题是把在您的依赖关系块下面应用插件:'com.google.gms.google-services'行,该插件允许插件确定您正在使用的Play服务的版本。既然你已经做到了,试着下载 Google Support Repository 。您可以在工具 - > Android - > SDK Manager SDK Tools

=https://stackoverflow.com/questions/38127053/google-play-services-gcm-9-2-0-asks-to-update-back-to-9-0-0> Google Play Services GCM 9.2 .0要求更新回到9.0.0


When i try to compile my app with flavors based on minSdk i receive an error:

Error:Execution failed for task ':app:processCurrentDebugGoogleServices'.

Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 10.2.0.

I pasted example from Android Developers Blog and it's not working.

project gradle:

// 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
}

app gradle:

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'

解决方案

One workaround for this issue is to put the apply plugin: 'com.google.gms.google-services' line below your dependencies block which allows the plugin to determine what version of Play services you are using. Since you've already done that, try to download Google Support Repository. You can find it in Tools -> Android -> SDK Manager -> SDK Tools.

You may also check the answers in this related SO post: Google Play Services GCM 9.2.0 asks to "update" back to 9.0.0

这篇关于无法使用Gradle和flavor和com.google.gms.google-services插件构建应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆