GCM google-services.json

时间:2016-03-02 10:57:23

标签: android gradle google-cloud-messaging google-play-services

I am creating a simple chat application. In which i am using Google Cloud Message(GCM). but when I add google play service and plugin: 'com.google.gms.google-services'. it gives error

File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it. Information:BUILD FAILED Information:Total time: 2.942 secs Information:1 error Information:0 warnings Information:See complete output in console

but I try to add google-services.json in app root.and i did not get any solution to add in app root.

build.gradle(Module:app)

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.dhananjay.chatserver"
    minSdkVersion 17
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library:1.0.6@aar'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
}

apply plugin: 'com.google.gms.google-services'

build.gradle(Project:XXXXX)

// 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:1.5.0'
    classpath 'com.google.gms:google-services:2.0.0-alpha6'


    // 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
}

1 个答案:

答案 0 :(得分:0)

试试这个link。如果您已经创建了一个项目,那么先选择该项目,然后下载相应的google-services.json文件并将其粘贴到项目的app目录中。