Usage Of Parceler (@parcel) With Realm.io (android)
Solution 1:
EDIT #2: Actually, I found a way to make it work :). See the updated answer below.
EDIT #1: While the app compiles just fine, it crashes when trying to actually create a Parcel
with the error: org.parceler.ParcelerRuntimeException: Unable to create ParcelableFactory for io.realm.FeedRealmProxy
. The Realm team has officially acknowledged that it is currently not possible to implement Parcelable
on RealmObject
s. It is unclear if / when this will be resolved.
With Parceler v0.2.16, you can do this:
@RealmClass// required if using JDK 1.6 (unrelated to Parceler issue)@Parcel(value = Parcel.Serialization.BEAN, analyze = { Feed.class })publicclassFeedextendsRealmObject {
// ...
}
Then, use Parcels.wrap(Feed.class, feed)
instead of Parcels.wrap(feed)
everywhere, otherwise your app will crash with org.parceler.ParcelerRuntimeException: Unable to create ParcelableFactory for io.realm.FeedRealmProxy
.
Solution 2:
All classes that extend RealmObject will have a matching RealmProxy class created by the annotation processor. Parceler must be made aware of this class. Note that the class is not available until the project has been compiled at least once.
@Parcel(implementations = { PersonRealmProxy.class },
value = Parcel.Serialization.BEAN,
analyze = { Person.class })publicclassPersonextendsRealmObject {
// ...}
Post a Comment for "Usage Of Parceler (@parcel) With Realm.io (android)"