Gradle 警告:查找时找不到 google-services.json

Gradle Warnings: Could not find google-services.json while looking in

我收到以下警告。 我怎样才能避免这个警告?

Could not find google-services.json while looking in [src/flavor1/debug, src/debug, src/flavor1] Could not find google-services.json while looking in [src/flavor1/release, src/release, src/flavor1] Could not find google-services.json while looking in [src/flavor2/debug, src/debug, src/flavor2] Could not find google-services.json while looking in [src/flavor2/release, src/release, src/flavor2]


我在 app/google-services 添加了两个 client_info。json

{
  "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"
}

Could not find google-services.json while looking in

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

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.

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

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