错误 :
任务':app:processDebugGoogleServices'的执行失败。请通过更新google-services插件的版本(有关最新版本的信息 此处可用 )或将com.google.Android.gms的版本更新为8.3.0来修复版本冲突。
我已经完成了我发现的所有事情。
dependencies {
// This does not break the build when Android Studio is missing the JRebel for Android plugin.
classpath 'com.zeroturnaround.jrebel.Android:jr-Android-gradle:1.0.+'
classpath 'com.Android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
并在应用程序gradle中
compile 'com.google.Android.gms:play-services:8.4.0'
将这些依赖项用于项目build.gradle
dependencies {
classpath 'com.Android.tools.build:gradle:2.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
}
并将其放在app级build.gradle文件的末尾(在依赖项之后)。
apply plugin: 'com.google.gms.google-services'
我不知道为什么把它放在最后(而不是在开头)解决了错误。
编辑5/1/2016
好的......所以试图结束你们所遇到的所有问题我的解决方案
这是我最后的应用程序级别
apply plugin: 'com.Android.application'
Android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "your-app-name"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.Android.support:appcompat-v7:23.1.1'
compile 'com.google.Android.gms:play-services:8.4.0'
compile 'com.Android.support:design:23.1.1'
compile 'com.mcxiaoke.volley:library:[email protected]'
}
apply plugin: 'com.google.gms.google-services'
这是我最后的项目级别
// 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.0.0-alpha3'
classpath 'com.google.gms:google-services:2.0.0-alpha3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
将其与您自己的gradle文件进行比较,并添加或修改任何与我编写的值不同的值。
在应用程序的模块(build.gradle)中
搬家:
apply plugin: 'com.google.gms.google-services'
到最后一行解决了这个问题。
请执行下列操作:
将以下内容放在build.gradle中(应用程序级gradle文件)
dependencies {
classpath 'com.Android.tools.build:gradle:2.0.0-beta2'
classpath 'com.google.gms:google-services:2.0.0-beta2'
}
请检查 这里 最新版本,因为这一直在变化。
插件太旧,请更新到更新版本,或设置Android_DAILY_OVERRIDE环境变量
将以下行放在build.gradle的底部(模块级gradle文件)
apply plugin: 'com.google.gms.google-services
这似乎是使用版本3.0.0的Google服务插件(以及Google Play服务库的9.0.0版本)修复的。所以这个
顶级build.gradle
dependencies {
classpath 'com.google.gms:google-services:3.0.0'
}
app level build.gradle
apply plugin: 'com.google.gms.google-services'
dependencies {
compile 'com.google.Android.gms:play-services:9.0.0
}
快速注意: 如果要更新到google-services
插件的3.0.0版,请确保重新生成配置文件,因为它有新字段(解释 此处 )。
编辑(2016-06-20): 虽然这确实编译并运行,但我注意到在构建日志中它确实指定将插件放在文件的底部,或默认值(9.0。 0)将被使用。因此,在上面的情况下,这不是问题,因为我使用的是9.0.0版,但在更新依赖项时这可能会有问题。这是日志:
google-services plugin could not detect any version for com.google.Android.gms or com.google.firebase, default version: 9.0.0 will be used. please apply google-services plugin at the bottom of the build file.
对我来说只有这个:
顶层。
dependencies {
classpath 'com.Android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
应用级别:
dependencies {
compile 'com.google.Android.gms:play-services-gcm:9.0.1'
compile 'com.google.Android.gms:play-services-location:9.0.1'
}
// should be at the bottom
apply plugin: 'com.google.gms.google-services'
在官方例子中找到
在项目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.0.0-alpha9'
classpath 'com.google.gms:google-services:2.0.0-alpha9'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
在app gradle中
apply plugin: 'com.Android.application'
Android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.google.samples.quickstart.signin"
minSdkVersion 18
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "Android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-Android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
// Resolve dependency differences between app and tests
configurations.all {
resolutionStrategy.force 'com.Android.support:support-annotations:23.1.1'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.Android.support:appcompat-v7:23.1.1'
compile 'com.Android.support:design:23.1.1'
// Dependency for Google Sign-In
compile 'com.google.Android.gms:play-services-auth:8.4.0'
// UiAutomatorTesting
androidTestCompile 'com.Android.support.test:runner:0.4.1'
androidTestCompile 'com.Android.support.test:rules:0.4.1'
androidTestCompile 'com.Android.support.test.uiautomator:uiautomator-v18:2.1.2'
androidTestCompile 'com.Android.support:support-annotations:23.1.1'
}
apply plugin: 'com.google.gms.google-services'
我已经在app build.gradle中更新了
dependencies {
....
compile 'com.google.Android.gms:play-services-auth:9.0.0'
和app build.gradle
dependencies {
classpath 'com.Android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:3.0.0'
}
它的工作。
在我的情况下,我已从gradle.build的末尾删除了“apply plugin:'com.google.gms.google-services'”并且工作正常。
重要的是 将Gradle设置为版本2.10
移动apply插件没有任何意义:'com.google.gms.google-services
'到 build.gradle 的结尾。它与未定义它相同。
只需删除此行,并确保应用插件:'com.Android.application
'就在那里
使用:
compile 'com.google.Android.gms:play-services-gcm:8.4.0'
compile 'com.google.Android.gms:play-services:8.4.0'
它会编译。
我在浏览...在Google页面上有解决方案... https://developers.google.com/Android/guides/google-services-plugin#introduction
添加已启用服务所需的基本库的依赖项。此步骤需要应用插件:'com.google.gms.google-services'行位于app/build.gradle文件的末尾,以便不会引入任何依赖项冲突。您可以通过运行./gradlew:app:dependencies来查看此步骤的结果。
在项目gradle中
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
}
在app/module gradle中
apply plugin: 'com.google.gms.google-services'
Android {
...
}
dependencies {
compile 'com.google.Android.gms:play-services-analytics:8.3.0'
}