1
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;
    }
}

提前谢谢了,

4

1 回答 1

0

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

@Parcel(implementations = {PersonRealmProxy.class},
        value = Parcel.Serialization.BEAN,
        analyze = {Person.class})
于 2016-11-03T00:14:10.340 回答