我正在创建一个简单的聊天应用程序。我在其中使用谷歌云消息(GCM)。但是当我添加谷歌播放服务和插件时:'com.google.gms.google-services'。它给出了错误
模块根文件夹中缺少文件 google-services.json。没有它,Google 服务插件将无法运行。信息:BUILD FAILED 信息:总时间:2.942 秒 信息:1 错误 信息:0 警告 信息:查看控制台中的完整输出
但我尝试在应用程序根目录中添加 google-services.json。我没有得到任何解决方案来添加应用程序根目录。
build.gradle(模块:应用程序)
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(项目: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
}
最佳答案
试试这个link .如果您已经创建了一个项目,请先选择该项目,然后下载其相应的 google-services.json 文件并将其粘贴到项目中的应用目录中。
关于android - GCM google-services.json,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35745229/