请确保以下代码位于应用程序的 build.gradle 文件末尾:
Make sure that the following line is at the end of the app build.gradle file:
apply plugin: 'com.google.gms.google-services'
我的问题是,gradle默认使用8.3.0而不是指定的8.4.0版本。我的build.gradle文件与Version conflict updating to 8.4.0中的文件相同。
由于以前的答案只是部分完成。
这里是我的三个步骤,对我来说效果很好:
将以下内容放置在您的应用程序 build.gradle
末尾:
apply plugin: 'com.google.gms.google-services'
将项目的build.gradle
依赖项设置为:
'classpath 'com.google.gms:google-services:2.0.0-alpha5''
将Gradle版本设置为2.10
Android Studio:文件>项目结构>项目
build.gradle
中使用它,并且它可以正常工作。 - CWittyapply plugin: 'com.google.gms.google-services'
放在依赖项之后即可。dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.google.gms:google-services:2.0.0-alpha6'
}
build.gradle(模块:app)
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:8.4.0'
}
apply plugin: 'com.google.gms.google-services'
com.android.application
插件之前。apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.android.application'
同时,Google服务的最新二进制文件已经更新,比alpha版本更加先进。
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:2.0.0-beta6'
}
}
我相信很快就会有更新的版本。我在这里找到了变体的列表(点击此处)
。请按照以下链接中的所有步骤进行操作:将应用邀请添加到您的应用中
使用此语句:compile 'com.google.android.gms:play-services-appinvite:8.4.0'
而不是此语句:compile 'com.google.android.gms:play-services:8.4.0'
请遵循所有步骤,然后构建项目。
希望这能帮助到您。
我有同样的问题,后来发现将:
apply plugin: 'com.google.gms.google-services'
移动到模块app gradle文件的底部。
然后使用:
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:2.1.0'
// 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.1.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
}
// this should solve the gradle update error if it persists even after following above steps
请检查您的应用程序build.gradle文件中是否存在这些问题。
compile 'com.google.android.gms:play-services-plus:8.4.0'
compile 'com.google.android.gms:play-services-analytics:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-maps:8.4.0'
在你的项目 build.gradle 文件中添加以下内容:
classpath 'com.google.gms:google-services:1.5.0'
您可以更新项目的 build.gradle 文件以使用最新的 google-services 版本,或者只需更改应用程序依赖项以使用 8.3 版本。
compile 'com.google.android.gms:play-services:11.0.2'
谷歌每天都在更新他们的API。现在我的API版本是'11.0.2',建议尝试使用最新的API。