简体   繁体   English

google-services.json api_key 从 firebase 为空

[英]google-services.json api_key is empty from firebase

When I followed https://codelabs.developers.google.com/codelabs/flutter-firebase/ and I downloaded google-services.json I get this error when trying to run the flutter app on android. When I followed https://codelabs.developers.google.com/codelabs/flutter-firebase/ and I downloaded google-services.json I get this error when trying to run the flutter app on android.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugGoogleServices'.
> Missing api_key/current_key object

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

* Get more help at https://help.gradle.org

BUILD FAILED in 21s
Finished with error: Gradle build failed: 1

Now in my google-services.json I can see that the api_key array is emtpy:现在在我的 google-services.json 中,我可以看到 api_key 数组是空的:

"api_key": [],

I tried to download new google-services.json but with the same result.我尝试下载新的 google-services.json 但结果相同。

Anyone knows how to generate api_key?任何人都知道如何生成 api_key?

First, access the Firebase Console.首先,访问 Firebase 控制台。

Select your project, Access the "Project Settings" (Can be accessed by clicking on "Project Overview"). Select 您的项目,访问“项目设置”(可以通过单击“项目概述”访问)。

Now, click on the "3 dots", and then click on "Settings".现在,单击“3 个点”,然后单击“设置”。

On the "Project Settings" screen, copy the "Web API Key" (Example: AIzaSyAjo3TYy8p_mjj3jMDcxTPrkwDF2dL8lwl).在“项目设置”屏幕上,复制“Web API 密钥”(示例:AIzaSyAjo3TYy8p_mjj3jMDcxTPrkwDF2dL8lwl)。

Now go to your project and go to the "google-services.json" file (located under " \ android \ app \ google-services.json")现在 go 到您的项目,go 到“google-services.json”文件(位于“\android\app\google-services.json”下)

Find in the file code "google-services.json" the line with the following code:在文件代码“google-services.json”中找到包含以下代码的行:

"api_key": [],

Inside the brackets "[]" put the following code:在括号“[]”内放入以下代码:

{
  "current_key": "<paste here your Web API Key>"
}

Paste your Web API Key between double quotation marks (see example below):将您的 Web API 键粘贴在双引号之间(参见下面的示例):

"api_key": [
    {
      "current_key": "AIzaSyAjo3TYy8p_mjj3jMDcxTsdFkwDF2dL8NWs"
    }
],

Open CMD as Admin and run this:以管理员身份打开 CMD 并运行:

keytool -genkeypair -alias androiddebugkey -keypass android -keystore debug.keystore -storepass android -dname "CN=Android Debug,O=Android,C=US" -validity 9999

It will create a debug.keystore file in C drive.它将在 C 驱动器中创建一个 debug.keystore 文件。

Thanks谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 Firebase 控制台下载 google-services.json 文件 - Unable to download google-services.json file from Firebase Console google-services.json Google Cloud out-login和Firebase动态链接同一个项目android - google-services.json Google Cloud outh login and Firebase dynamic link same project android 由以下原因引起:org.gradle.api.GradleException:文件 google-services.json 丢失。 没有它,谷歌服务插件就不能 function - Caused by: org.gradle.api.GradleException: File google-services.json is missing. The Google Services Plugin cannot function without it Flutter:文件 google-services.json 丢失。 没有它,Google 服务插件不能 function - Flutter : File google-services.json is missing. The Google Services Plugin cannot function without it google-services.json”已找到,但它表明您似乎无权访问的项目 ID - google-services.json" was found, but it indicates a project ID that you don't appear to have access to 如何将 google-services.json 文件放入 android 项目中的自定义位置 - How google-services.json file can be put to custom location within android project 如何在开发环境中使用没有服务 key.json 文件的谷歌服务,如 bucket 或 pub sub? - How to use the google services like bucket or pub sub without service key.json file in development environment? Firebase - 什么是 API 密钥 - Firebase - What is the API Key 从 CoderRegistry 推断编码器失败:无法为 com.google.api.services.bigquery.model.TableRow 提供编码器 - Inferring a Coder from the CoderRegistry failed: Unable to provide a Coder for com.google.api.services.bigquery.model.TableRow 显示来自 Firebase 数据库的密钥 - Display a Key from Firebase Database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM