我将我的项目更新到最新的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.

当前回答

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

选择开始,进入设置logo,然后是项目设置 之后,你会看到下面的平台,如web,android,ios。根据您的喜好选择。 然后下载 google服务。json文件

复制该文件并粘贴到

YourProjec / app目录 最后再次同步。

其他回答

非常简单的 点击工具->Firebase->连接到Firebase,然后点击同步 这肯定会奏效。

在你的Android Studio中找到工具>Firebase,然后点击连接你的应用到Firebase。他们会帮你安排的。

对于Cordova应用程序:

我们需要放置谷歌服务。json文件在应用程序根(我相信;当使用Cordova应用程序时,我们不进入其他文件夹/文件,如Gradle, Java文件,平台等;相反,只能通过config.xml和www文件夹来使用它们),并在config.xml中引用它,如下所示:

<platform name="android">
    <!-- Add this line -->
    <resource-file src="google-services.json" target="app/google-services.json" />
</platform>

注意:确保Firebase App packagename与<widget id="<packagename>"中的id属性相同…>是一样的。

为例:

<!-- config.xml of Cordova App -->
<widget id="com.appFactory.torchapp" ...>

<!--google-serivces.json from generated from Firebase console.-->
{
  ...
  packagename: "com.appFactory.torchapp",
  ...
}

祝你好运…

添加google-service最简单的方法。json文件

在Android Studio中遵循以下步骤:

单击“工具> Firebase”,打开“助手”窗口。

单击以展开列出的功能之一(例如“分析”),然后单击“入门”教程以连接到Firebase并将必要的代码添加到应用程序中。

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

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

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