簡體   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