【发布时间】:2015-11-11 09:35:05
【问题描述】:
错误是:
模块根文件夹中缺少文件 google-services.json。这 没有它,Google 快速入门插件将无法运行。
【问题讨论】:
-
我已经添加了这是在 app 文件夹中,虽然这个错误来了
标签: android google-play-services
错误是:
模块根文件夹中缺少文件 google-services.json。这 没有它,Google 快速入门插件将无法运行。
【问题讨论】:
标签: android google-play-services
根据 developer.google.com https://developers.google.com/cloud-messaging/android/client#get-config987654321@ 上的文档,上述问题已得到解决
文件google-services.json 应该粘贴到app/ 目录中。
在此之后,当我将项目与 gradle 文件同步时,出现了意外的顶级异常错误。这是因为:
项目级 Gradle 文件具有
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
应用级 Gradle 文件具有:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.google.android.gms:play-services:7.5.0' // commenting this lineworks for me
}
顶行是在这和classpath 'com.google.gms:google-services:1.3.0-beta1' 之间造成冲突所以我发表评论现在它工作正常并且没有错误
模块根文件夹中缺少文件 google-services.json。没有它,Google 快速入门插件将无法运行。
【讨论】:
将文件复制到您的 Android Studio 项目的
app/文件夹中,或者 如果您使用多个构建,则进入app/src/{build_type}文件夹 类型。
【讨论】:
而不是像 firebase 文档中给出的那样放入根文件夹,只需将 google-json 文件复制到 projectname/app 的根文件夹中,然后它就可以正常工作了。 它很简单!
【讨论】:
WINDOWS
(Alt+F12 or View->Tool Windows->Terminal).
然后输入 “移动文件路径/google-services.json app/”
没有双引号。
例如
move C:\Users\siva\Downloads\google-services.json app/
Linux
scp file_path/google-services.json app/
例如:
scp '/home/developer/Desktop/google-services.json' 'app/'
【讨论】:
单击应用程序的正上方,即android studio中的android(下拉列表)。从下拉列表中选择Project,然后通过右键单击应用包,然后同步它....
【讨论】:
此错误表明您的package_name 中的google-services.json 可能有误。我个人在使用时遇到过这个问题
buildTypes {
...
debug {
applicationIdSuffix '.debug'
}
}
在我的build.gradle。因此,当我想调试时,应用程序的名称是(“突然”)app.something.debug,而不是app.something。当我更改上述package_name时,我能够运行调试...
【讨论】:
【讨论】:
【讨论】:
google-services.json 文件像 API 密钥一样工作,这意味着它以 json 格式存储您的 project_id 和 api 密钥,用于所有 google 服务(由您在 google 控制台启用),因此无需在不同的地方管理所有服务。
你应该在应用程序 gradle 中添加
apply plugin: 'com.google.gms.google-services'.
在顶层 gradle 你应该添加下面的依赖
dependencies {
// Add this line
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
}
【讨论】: