我正在使用GCM应用程序并添加支持库,我将以下内容添加到我的gradle中
我添加了一个插件
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
和依赖项:我补充说:
compile 'com.google.android.gms:play-services:8.3.0'
classpath 'com.google.gms:google-services:3.0.0'
但它带来了错误
Error:(3, 0) Plugin with id 'com.google.gms.google-services' not found.
但我看到插件已添加。我该如何纠正呢谢谢
答案 0 :(得分:0)
在您的项目级build.gradle
中添加如下内容:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
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
}
}
虽然您的应用级build.gradle
应如下所示:
apply plugin: 'com.android.application'
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.google.android.gms:play-services-gcm:8.3.0"
}
apply plugin: 'com.google.gms.google-services'
确保在应用级草图文件中添加apply plugin: 'com.google.gms.google-services'
作为最后一行。
答案 1 :(得分:0)
您应该只应用com.android.application插件。
同样应用java插件会导致构建错误。 参考:http://tools.android.com/tech-docs/new-build-system/user-guide
您添加的依赖项很好。您可以删除" apply插件:' com.google.gms.google-services'"条目。