Dak*_*wal 25 java android firebase
我在应用程序启动状态日志上收到一条错误消息,例如
W/Firebase-Installations: Error when communicating with the Firebase Installations server API. HTTP response: [400 Bad Request: {
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.Help",
"links": [
{
"description": "Google developers console",
"url": "https://console.developers.google.com"
}
]
}
]
}
}
]
2020-04-27 12:42:34.621 22226-23596/in.co.androidapp.g7 E/Firebase-Installations: Firebase Installations can not communicate with Firebase server APIs due to invalid configuration. Please update your Firebase initialization process and set valid Firebase options (API key, Project ID, Application ID) when initializing Firebase.
Run Code Online (Sandbox Code Playgroud)
大约一周前我收到一封电子邮件,说我应该更新我的 google_services.json 文件,我已经做了 4-5 次。没有改进。它已经运行了大约一年。自从我在应用程序中遇到这个问题以来只有 2-3 天。
随后,Firebase Cloud Messaging 和其他 Firebase 服务无法正常工作。我没有进行编程初始化(即,使用 FirebaseOptions 对象来提供这些值),只是使用默认初始化FirebaseApp.initializeApp(this);
提前致谢。
Abh*_*mal 21
我有同样的问题。我通过以下方式解决了它。
转到 app/build/generated/res/google-services/debug/values/values.xml
在这里您可以找到旧的 API 密钥。
将 google_api_key 和 google_crash_reporting_api_key 值替换为您可以从 google-services.json 文件中找到的新值。它将在 api-key 数组下。
干杯!
And*_*iep 17
如果您的 API 密钥有问题,您可以在 Cloud Console 中创建一个新的 API 密钥:
APIs & Services?Credentials+ CREATE CREDENTIALS?API key如果您使用Firebase 控制台中的google-services.json配置文件,您首先必须删除或限制当前使用的 API 密钥,以便 Firebase 更新配置文件并使用新的 API 密钥。google-services.json
google-services.json配置文件中的 API 密钥。Usage with this serviceAPI 密钥的列应显示大于 0 的数字。Application restrictions通过单击铅笔符号添加到该 API 密钥。!!警告!!不要删除现有应用程序安装所需的其他 Firebase 服务(例如 Firebase Auth 或 Realtime-Database)所需的 API 密钥。等待几分钟,让 Google 服务器更新。google-service.json配置文件的下一次下载应该包含一个新的 API 密钥。
您可以使用以下 CURL 命令测试您的配置。你得到的错误是什么?(注意:如果您看到的是请求是 JSON 数据并且您的配置成功)
测试您的配置是否适用于以下 CURL 命令:
api_key=<YOUR_API_KEY>;
project_identifier=<YOUR_PROJECT_ID>;
app_id=<YOUR_FIREBASE_APP_ID_EXAMPLE_1:12345678:android:00000aaaaaaaa>;
curl -H "content-type: application/json" -d "{appId: '$app_id', sdkVersion: 't:1'}" https://firebaseinstallations.googleapis.com/v1/projects/$project_identifier/installations/?key=$api_key;
Run Code Online (Sandbox Code Playgroud)
有关 API 密钥和Firebase 安装 API 的其他相关链接:
迟到但可能对其他人有帮助。
我在这里尝试了一切,最后通过确保以下步骤使其工作,
规则:应用程序的 SHA-1 应使用所使用的 API 密钥在 Google Developer Console 中注册。
查找您正在使用的 SHA-1(调试或发布)。您可以通过转到 android studio > Gradle 表单侧栏 > 任务 > android > 签名报告来完成。双击它运行。运行后,您将能够为您的变体找出 SHA-1。(就我而言,我试图让它运行发布版本)。将 SHA-1 放在一边,我们将在 Google Developers Console 上检查它是否存在。
现在转到https://console.cloud.google.com/apis/credentials,在您选择的项目 > 凭证中,查找使用的 API 密钥,单击它进入详细信息,查找Restrict usage to your Android apps,查看 SHA-1与您的包名一起在那里注册。
如果您没有在您的项目中找到相同的 SHA-1,那么您可以单击Add an Item添加应用程序。传递包名和 SHA-1 并提交。
5-10 分钟后再次尝试连接 firebase API。
| 归档时间: |
|
| 查看次数: |
29773 次 |
| 最近记录: |