错误是:
文件 google-services.json 不存在于模块根目录中。没有该文件,Google Quickstart 插件无法正常工作。
错误是:
文件 google-services.json 不存在于模块根目录中。没有该文件,Google Quickstart 插件无法正常工作。
文件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'
冲突了,所以我现在注释掉它,这样就可以正常工作了,没有 "File google-services.json is missing from module root folder. The Google Quickstart Plugin cannot function without it." 这个错误了。
将文件复制到Android Studio项目的
app/
文件夹中,或者如果您正在使用多个构建类型,则将其复制到app/src/{build_type}
文件夹中。
不要按照Firebase文档中给出的方式将文件放在根目录中,而是将Google JSON文件复制到项目名称/应用程序的根目录中即可正常工作。这很简单!
WINDOWS
(Alt+F12或View->Tool Windows->Terminal)
,然后输入"move file_path/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(下拉列表)的右侧单击。从下拉菜单中选择项目,通过在应用程序包上右键单击并同步来粘贴json文件....
google-services.json
文件中的package_name
可能是错误的。我个人在使用时也碰到了这个问题。buildTypes {
...
debug {
applicationIdSuffix '.debug'
}
}
在我的build.gradle
文件中,当我想要调试时,应用程序的名称突然变成了app.something.debug
而不是app.something
。当我更改了所述的package_name
后,我能够运行调试...
google-services.json文件像API密钥一样工作,这意味着它以json格式存储您的project_id和api密钥,用于所有启用了的谷歌服务(由您在谷歌控制台上启用),因此无需在不同位置管理所有内容。
在应用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
}