在类com.contentful.vault.Asset上找不到要序列化的属性 [英] No properties to serialize found on class com.contentful.vault.Asset

查看:39
本文介绍了在类com.contentful.vault.Asset上找不到要序列化的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在具有Asset属性的Firebase数据库上保存对象时遇到此错误. 在以下问题中也记录了类似的错误:

Am getting this error while trying to save an Object on the Firebase database that has an Asset property. Similar errors have been documented in the following questions:

Firebase在类上找不到要序列化的属性

Firebase没有可用于序列化的属性对象处于释放模式

和其他一些人.

一些推荐的解决方案是

  1. 将变量声明更改为public
  2. @Keep添加到类声明中
  3. 在Proguard规则中添加-keepclassmembers class com.yourcompany.models.** { *; }
  1. Change variable declarations to public
  2. Add @Keep to the class declaration
  3. Add -keepclassmembers class com.yourcompany.models.** { *; } in Proguard-rules

但是这些选项都不适合我.

but none of these options have worked for me.

我尝试过的是创建另一个类,该类是用于Vault的类的副本,然后具有一个String属性,该属性保存AssetURL,但这似乎是重复的代码和不必要的.

What I've tried is create another class that is a replica of the class am using for Vault and then have a String property that holds the URL of the Asset but this seems like duplication of code and unnecessary.

这个问题有解决方案吗?

Is there a solution to this problem?

推荐答案

我是Mario Bodemann,他是Contentful的Java和Android SDK的维护者.

I am Mario Bodemann, a maintainer of the Java and Android SDKs of Contentful.

我也建议按照您的建议将Firebase用例和Contentful用例之间的关注点分开.

I would recommend separating the concerns between the Firebase use-case and the Contentful use-case, as you suggested too.

通过这种方式,您可以确保为Firebase提供所需的模型,并为Firebase提供所需的模型,而无需将两者混合在一起.我不认为它是重复代码,您正在重复数据.对于不同的用例来说应该没问题.

This way you can make sure to provide Firebase with a model that it needs and Contentful with a model that it needs, without intermixing both. I don't see it as repeating code, you are repeating data. And that should be alright for different use-cases.

也许有些工厂可以根据需要将一种形式转换为另一种形式.

Probably some factories for converting from one form to the other on a per need basis would be convenient too.

否则,如果您可以在一个应用程序中分享有关两者的更多使用信息,我们可以为您提供更多帮助...

Otherwise, maybe if you could share a bit more about your use of both in one app, we could be able to help you a bit more...

问候, 马里奥(Mario)

Greetings, Mario

这篇关于在类com.contentful.vault.Asset上找不到要序列化的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆