小编dbe*_*gan的帖子

如何将我的 MAUI 应用连接到 Firestore 数据库?(通过服务帐户 json 文件)

创建一个 MAUI 应用程序并尝试将其连接到 Firestore。我按照此处的建议下载服务帐户 JSON 文件并设置GOOGLE_APPLICATION_CREDENTIALS环境变量。

我从我的 firebase 项目在线下载了我的服务文件,将其重命名为GoogleAppCredentials.json,然后使用构建操作“MauiAsset”将其包含在我的 MAUI 项目中,如下所示:

GoogleAppCredentials 位置

然后我的 cs 文件引用该文件:

string path = "GoogleAppCredentials.json";
Environment.SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", path);
Run Code Online (Sandbox Code Playgroud)

但是当我在 Android 模拟器上运行该应用程序时,出现以下错误:

System.AggregateException
  Message=One or more errors occurred. (Error reading credential file from location GoogleAppCredentials.json: Could not find file '/GoogleAppCredentials.json'.
Please check the value of the Environment Variable GOOGLE_APPLICATION_CREDENTIALS)
Run Code Online (Sandbox Code Playgroud)

在 Windows 机器上...

System.AggregateException
  Message=One or more errors occurred. (Error reading credential file from location GoogleAppCredentials.json: Could not find file 'C:\WINDOWS\system32\GoogleAppCredentials.json'.
Please …
Run Code Online (Sandbox Code Playgroud)

.net c# firebase google-cloud-firestore maui

6
推荐指数
1
解决办法
3425
查看次数

标签 统计

.net ×1

c# ×1

firebase ×1

google-cloud-firestore ×1

maui ×1