无法为io.realm.PersonRealmProxy找到生成的Parcelable类

时间:2016-11-02 23:59:16

标签: android realm parceler

Realm 2.0.0
Parceler 1.1.6

我正在尝试将Parceler库与我的POJO类一起使用,该类也用于我的Android应用程序中的领域。

但是,这行代码会崩溃

Bundle bundle = new Bundle(1);
bundle.putParcelable(UpdatePersonDialog.PERSONUPDATE_KEY, Parcels.wrap(person)); /* Crash line */

这是错误信息:

Unable to find generated Parcelable class for io.realm.PersonRealmProxy, verify that your class is configured properly and that the Parcelable class io.realm.PersonRealmProxy$ $Parcelable is generated by Parceler

我已经宣布了这样的依赖:

compile 'org.parceler:parceler:1.1.6'
apt 'org.parceler:parceler:1.1.6'

有没有办法解决这个问题?

这是我正在使用的课程

@Parcel(analyze = Person.class)
public class Person extends RealmObject{
    @PrimaryKey
    String mId;
    String mFirstName;
    String mLastName;
    String mPhoneNumber;
    String mDob;
    String mZip;

    public Person() {
    }

    public Person(String mDob, String mFirstName, String mId, String mLastName, String mPhoneNumber, String mZip) {
        this.mDob = mDob;
        this.mFirstName = mFirstName;
        this.mId = mId;
        this.mLastName = mLastName;
        this.mPhoneNumber = mPhoneNumber;
        this.mZip = mZip;
    }

    @Override
    public boolean isManaged() {
        return super.isManaged();
    }

    public String getId() {
        return mId;
    }

    public void setId(String id) {
        this.mId = id;
    }

    public String getDob() {
        return mDob;
    }

    public void setDob(String dob) {
        this.mDob = dob;
    }

    public String getFirstName() {
        return mFirstName;
    }

    public void setFirstName(String firstName) {
        this.mFirstName = firstName;
    }

    public String getLastName() {
        return mLastName;
    }

    public void setLastName(String lastName) {
        this.mLastName = lastName;
    }

    public String getPhoneNumber() {
        return mPhoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.mPhoneNumber = phoneNumber;
    }

    public String getZip() {
        return mZip;
    }

    public void setZip(String zip) {
        this.mZip = zip;
    }
}

非常感谢,

1 个答案:

答案 0 :(得分:0)

如果其他人有同样的问题,请找到答案:

@Parcel(implementations = {PersonRealmProxy.class},
        value = Parcel.Serialization.BEAN,
        analyze = {Person.class})