没有google-services.json,Google服务插件无法运行

时间:2017-03-19 14:55:05

标签: android json android-studio google-signin google-authentication

  

文件google-services.json缺失。 Google服务插件无法正常运行

我收到此错误代码,因为我从项目中删除了google-services.json文件。现在解决这个问题的明显方法是再次包含它,但我有理由将其删除。

Note: If you enabled only Google Sign-In when you generated the configuration file, you can skip this step. Google Sign-In does not require the configuration file to be included in your project—generating the file performs the neecessary configuration steps.” - 这是文档中的官方说明,因为我只启用了Google登录我没有看到此错误消息的原因。有没有人也有这个问题,并解决它,因为我认为我实现了一切正确。

注意: 包含项目中的文件。

编辑:为了澄清,我的应用程序完全正常,我没有问题,但我想知道为什么我无法删除google-services.json文件,即使我应该能够没问题!

3 个答案:

答案 0 :(得分:8)

在应用级apply plugin: 'com.google.gms.google-services'中添加build.gradle时,它会解析google-services.json文件中的配置信息。

您删除了google-services.json文件,这就是无法解析的原因。因此,从触发解析的应用级build.gradle中删除以下行也是为了让它再次运行。< / p>

apply plugin: 'com.google.gms.google-services'

答案 1 :(得分:1)

classpath和apply引用的gradle-plugin google-services只是一个构建时插件!所以它只影响你的应用程序的构建过程,而不影响运行时进程! 这就是为什么你的应用程序工作正常但需要google-services json。

答案 2 :(得分:-1)

您正在使用Google登录吗?所以你肯定需要一个google-services.json文件

参考此链接

https://developers.google.com/identity/sign-in/android/start-integrating

将依赖项添加到项目级build.gradle:

  

classpath&#39; com.google.gms:google-services:3.0.0&#39;

将插件添加到您的应用级build.gradle:

  

应用插件:&#39; com.google.gms.google-services&#39;