模块根文件夹中缺少文件 google-services.json。没有它,Google 服务插件无法运行

File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it

我有一个包含 1 个模块和 2 个应用程序的项目。该模块用于两个应用程序都使用的代码部分。当然,我在应用程序的根文件夹中有单独的 google-services.json 文件。

上周五构建运行良好。

现在我尝试编译并得到这个错误:

File google-services.json is missing from module root folder. The Google Services Plugin cannot function without it.
:DoToDoSenderApp:compileDebugSources
:DoToDoSenderApp:transformClassesWithDexForDebug
UNEXPECTED TOP-LEVEL EXCEPTION:
Error:Execution failed for task ':DoToDoSenderApp:transformClassesWithDexForDebug'.
> com.android.build.transform.api.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2

唯一的信息性错误消息是关于我的模块根文件夹中缺少此 google-services.json 文件。

不知道这里有什么问题?

该模块不是一个应用程序,为什么我必须添加一个 google-services.json 文件,为什么它几天前没有修改就可以工作?

编辑

我在 Google API 控制台中创建了一个新的 Google 应用程序,并在我的模块中添加了一个新的 google-services.json 文件,得到了同样的错误。

在你的项目应用 gradle 文件中添加 multiDexEnabled true 并检查,

defaultConfig {
    multiDexEnabled true
}

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

  1. 转到 firebase 控制台

  2. 创建一个新项目。

  3. 然后点击将 Firebase 添加到您的 Android 应用

  4. 添加包名(来自AndroidManifest.xml)

  5. 然后生成google-services.json

  6. 复制此文件并将其添加到 (i) 您的项目根目录 (ii) 您的项目>app

  7. 同步项目(工具 -> Android -> 与 Gradle 文件同步项目)

希望对您有所帮助:)

如果您无法访问项目的 Firebase,例如,您下载了一个示例源代码,那么您必须删除任何与 Firebase 相关的内容才能创建项目 运行.

在项目中搜索关键字

  • 面料
  • 火力基地
  • google-服务
  • crashlytics

If you want to use firebase or other google cloud platform then download google-services.json from link - https://console.firebase.google.com/u/0/project/raafta-aac07/settings/general/

否则你不想使用它,只需删除 apply plugin: 'com.google.gms.google-services' 来自 build.gradle 来自 Android 工作室