我用android studio开发android项目。我想在kotlin中使用onSaveInstanceState()保存realm对象。我的代码是
@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中编译得很好。
我需要你的帮助。
发布于 2016-11-11 17:14:07
您可能会注释到setter。请试一下这个。
@Parcel( implementations = arrayOf(UserRealmProxy::class),
value = Parcel.Serialization.BEAN,
analyze = arrayOf(User::class))
open class User : RealmObject() {
open var name: String? = null
open var Items: RealmList<Item>? = null
@ParcelPropertyConverter(ListParcelConverter::class) set
}发布于 2019-03-12 20:26:23
在我的例子中,当我遇到这个错误时:‘未解析的引用: UserRealmProxy’。如果我有这个包: com.path.model.Album,我必须使用:
import io.realm.com_path_model_AlbumRealmProxy
...
@Parcel(implementations = arrayOf(com_path_model_AlbumRealmProxy::class)https://stackoverflow.com/questions/38910246
复制相似问题