繁体   English   中英

带有Google Cloud消息传递的android推送通知库

[英]android push notifications library with google cloud messaging

我正在使用GCM应用程序并添加支持库在android上工作,我在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.

但是我看到插件添加了。 我如何纠正它,谢谢

在您的项目级别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'

确保在应用程序级别gradle文件的最后一行添加apply plugin: 'com.google.gms.google-services'

您应该只应用com.android.application插件。

应用Java插件也会导致生成错误。 参考: http : //tools.android.com/tech-docs/new-build-system/user-guide

您添加的依赖关系很好。 您可以删除“应用插件:'com.google.gms.google-services'”条目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM