【问题标题】:Linking Xamarin Forms to Firestore将 Xamarin 表单链接到 Firestore
【发布时间】:2019-11-13 19:10:46
【问题描述】:

我在将 Xamarin Forms 链接到 Firestore 时遇到问题。我在 Firebase 的 Firestore 数据库中有一个名为 Candidates 的集合,我正在使用 Plugin.CloudFirestore nuget 来链接 Firestore 和 Xamarin 表单

我已尝试使用以下链接中的“获取”示例:

https://github.com/f-miyu/Plugin.CloudFirestore

        var query = await CrossCloudFirestore.Current
                                    .Instance
                                    .GetCollection("Candidates")
                                    .GetDocumentsAsync();


        var documents = query.ToObjects<Candidate>();

当我运行代码时,我收到以下消息

“未处理的异常: Java.Lang.IllegalStateException:名为 [FirebasePlugin] 的 FirebaseApp 不存在。”

对出了什么问题有什么想法吗?

【问题讨论】:

标签: firebase xamarin.forms google-cloud-firestore


【解决方案1】:

您是否按照说明进行操作?

  • 将 google-services.json 添加到 Android 项目。选择 GoogleServicesJson 作为构建操作。 (如果无法选择 GoogleServicesJson,请重新加载此 android 项目。)
  • 目标框架必须是 Android 9.0 (Pie)。如果您使用其他库、Xamarin.Forms 等,则需要启用 Multi-Dex。

    <TargetFrameworkVersion>v9.0</TargetFrameworkVersion>
    <AndroidEnableMultiDex>true</AndroidEnableMultiDex>
    

https://github.com/f-miyu/Plugin.CloudFirestore#android

【讨论】:

  • 是的,我按照说明进行操作。仍然不确定为什么它不起作用。
  • 也许我必须在某处添加我的 Firebase 应用程序名称,但教程没有说明在哪里。
  • github.com/f-miyu/Plugin.CloudFirestore/issues/… 和你的类似,尝试调用 Plugin.CloudFirestore.CloudFirestore.Init();
  • 好的,我已经添加了 Plugin.CloudFirestore.CloudFirestore.Init(Application.Context);但现在我得到:未处理的异常:Java.Lang.NullPointerException:尝试从空对象引用上的字段“java.lang.String com.google.firebase.FirebaseOptions.zzehy”读取
猜你喜欢
  • 2019-09-24
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 2012-11-07
  • 1970-01-01
  • 1970-01-01
  • 2017-12-14
相关资源
最近更新 更多