我将我的项目更新到最新的Play服务类路径“com.google.gms:google-services:1.5.0-beta2”。我也在我的app.gradle文件中使用最新版本的playservices:

compile 'com.google.android.gms:play-services-location:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'

然而,当我编译时,Gradle抛出异常如下

Error:Execution failed for task ':app:processDebugGoogleServices'. > File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it.

当前回答

在android studio中:

切换到项目视图,这样你就可以看到实际的项目文件夹结构。 发现谷歌服务。json文件,并将其拖到app目录(由于某种原因,当我使用文件资源管理器添加它时,它把它放在gradle文件夹中)。 清洁/重建项目。

从那以后我就很顺利了。

其他回答

请访问这个URL:

https://developers.google.com/mobile/add

选择你的选项,最后你将能够下载

google服务。json文件

复制该文件并粘贴到

YourProjectName / app目录

然后重新编译项目,它很可能会飞

在我的例子中,项目目录看起来像这样:

也面临过同样的问题…

在我的情况下,我已经拯救了

google-services.json

as

google_services.json

我尝试了上面提到的每一种解决方案,但都没有帮助…… 错误是你需要把“_”换成“-”(破折号)。

只是将文件重构到google-services。来自google_services的Json。Json工作很有魅力..

希望这能有所帮助!!

附注:我知道这听起来很傻,但这只对我有用……

即使在添加了所有依赖项和文件之后,如果你遇到任何这样的问题,它可能是你不正确的文件名“google-services.json”。

请确保您有确切的文件名,没有任何额外的空格或字符。

我已经重命名了文件,在我的文件名中有空格“”,这是不明显的,后来我发现我的文件名是错误的,所以修正它!

对于从firebase codelabs教程第3步来到这里的人:请转到第4页。

Apparently, if google says You should now have the android-start project open in Android Studio. ,She means it,and not You should now have the android-start project open in Android Studio, without any build-errors . As the instruction says there, you have to get a configuration file from firebase. i.e , create a new project in your firebase acc with name 'friendly chat and in the next page , add its package name and SHA1 KEY. after downloading the json file,add it to your project>app folder, and Rebuild project.

这个问题是因为:-您粘贴到从firebase控制台下载的产品的文件夹或文件没有命名为google-services.json。点击它,然后在所有选项中单击鼠标右键打开折射器并将其重命名为google-services。json。因为这对我很管用