【问题标题】:Generic wildcard types are not supported不支持通用通配符类型
【发布时间】:2018-04-21 19:01:19
【问题描述】:

我收到以下错误:

无法反序列化对象。不支持通用通配符类型(在字段 m1(Map<String,Any>).someStringInM1(String) 中找到)

此错误是由以下行生成的(我使用的是 Firestore 的 Android SDK):

task.result.toObjects(SomeClass::class.java)

我试图将结果映射到具有以下构造函数的自定义类列表:

constructor(s1: String, s2: String, d1: Double, m1: Map<String, Any>, dr1: DocumentReference, i1: Int, d2: Double) {
        this.s1 = s1
        this.s2 = s2
        this.d1 = d1
        this.m1 = m1
        this.dr1 = dr1
        this.i1 = i1
        this.d2 = d2
    }

【问题讨论】:

  • someMapsomeString 是什么?
  • @OliverCharlesworth 刚刚编造了名字。错误消息指出在 m1 中存储的值中找到了通配符:Map.

标签: android firebase kotlin google-cloud-firestore


【解决方案1】:

在 Firebase SDK 的 release notes 中,它提到了版本 11.6.0:

功能:添加了对使用通配符通用参数(例如 kotlin.Map)反序列化字段类型的支持。

听起来您应该将客户端库升级到 11.6.0。

【讨论】:

  • 就是这样!解决了我的问题!
猜你喜欢
  • 2011-01-26
  • 2023-03-06
  • 2015-06-08
  • 2020-07-14
  • 2014-09-23
  • 2021-10-22
  • 2021-12-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多