【发布时间】:2016-08-12 04:59:33
【问题描述】:
我使用 android studio 开发 android 项目。
我想在 kotlin 中使用 onSaveInstanceState() 保存领域对象。
我的代码是
@Parcel( implementations = arrayOf(UserRealmProxy::class),
value = Parcel.Serialization.BEAN,
analyze = arrayOf(User::class))
open class User : RealmObject() {
open var name: String? = null
@ParcelPropertyConverter(ListParcelConverter::class)
open var Items: RealmList<Item>? = null
}
但是编译时出现一些错误:
'Unresolved reference: UserRealmProxy'
'An annotation parameter must be a compile-time constant'
当然,UserRealmProxy 已经存在,因为项目已经编译。
@ParcelPropertyConverter(ListParcelConverter::class) 也不起作用。
它会在运行时导致异常:
'java.io.NotSerializableException: io.realm.RealmList'
但是这段代码在java中编译得很好。
我需要你的帮助。
【问题讨论】:
-
您需要包裹而不是重新查询对象吗?
-
首先我收到了相同的消息
Unresolved reference: UserRealmProxy,但在构建项目后它消失了。 -
你能用
@field:ParcelPropertyConverter(ListParcelConverter::class)代替@ParcelPropertyConverter(ListParcelConverter::class)吗? -
我也有同样的问题。你解决了吗?
-
同样的问题..你找到解决方案了吗?