【问题标题】:Gradle Warnings: Could not find google-services.json while looking in [duplicate]Gradle 警告:在查看时找不到 google-services.json [重复]
【发布时间】:2018-05-13 22:16:29
【问题描述】:

我收到以下警告。 如何避免此警告?

在查看时找不到 google-services.json [src/flavor1/debug, src/debug, src/flavor1] 找不到 google-services.json 同时查看 [src/flavor1/release, src/release, src/flavor1] 找不到 google-services.json 而 查找 [src/flavor2/debug, src/debug, src/flavor2] 找不到 google-services.json 同时查看 [src/flavor2/release, src/release, src/flavor2]


我在 app/google-services.json

中添加了两个 client_info
{
  "project_info": {
    "project_number": "000000000000",
    "project_id": "****-*****"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": ...,
        "android_client_info": {
          "package_name": "flavor1.package.name"
        }
      },
      ...
    },
    {
      "client_info": {
        "mobilesdk_app_id": ...,
        "android_client_info": {
          "package_name": "flavor2.package.name"
        }
      },
      ...
    }
  ],
  "configuration_version": "1"
}

【问题讨论】:

标签: android gradle google-play-services android-flavors


【解决方案1】:

根据我的经验,当您使用与 firebase 相关的任何类型的服务并且您没有将 google-services.json 放入我们使用该服务所需的文件时,就会发生这种情况,

解决方案是您需要从 firebase 控制台获取文件,如果您要在控制台中为所有风格创建单个项目,则需要将文件放入应用级别文件夹中,如果您要创建不同的项目,则需要为多个项目或风格创建多个文件。

【讨论】:

  • 我在“/app/”文件夹中有这个文件,但找不到。相反,它一直在构建日志中向我显示:Could not find google-services.json while looking in [src/nullnull/debug, src/debug/nullnull, src/nullnull, src/debug, src/nullnullDebug] registerResGeneratingTask is deprecated, use registerGeneratedResFolders(FileCollection)
  • @androiddeveloper,使用最新的 google-services 版本(撰写本文时为 4.1.0)似乎可以修复它。
  • 这是 google 依赖中的一个问题,现在已在 com.google.gms:google-services:4.0.2 中修复
  • @ozbek .. 你的回答对我有用..
【解决方案2】:

在查看时找不到 google-services.json

根据 LOGCATgoogle-services.json 在正确的位置不存在(缺失)。

google-services.json文件一般放在app/ directory (at the root of the Android Studio app module).

例如,dogfood 和 release 是构建类型。

 app/
    google-services.json
    src/dogfood/google-services.json
    src/release/google-services.json
    ...

最后,Clean-Rebuild-Run

【讨论】:

  • 我已经将 google-services.json 文件放在了 app/ 目录中。我只是想隐藏那些警告。
  • @DrumRobot 阅读 developers.google.com/android/guides/google-services-plugin 。希望这对您有所帮助。
  • 我有两种不同的包名,但我在 app/ 的一个 google-services.json 文件中放置了两个 client_info目录
  • 这是 google 依赖中的一个问题,现在已在 com.google.gms:google-services:4.0.2 中修复
  • 我可以确认更新到 google-services:4.0.2 解决了我的问题。
猜你喜欢
  • 2021-06-11
  • 2019-11-27
  • 2016-07-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-22
  • 2018-02-06
  • 1970-01-01
相关资源
最近更新 更多