当前位置: 动力学知识库 > 问答 > 编程问答 >

android - Unable to find generated Parcelable class for io.realm.PersonRealmProxy

问题描述:

Realm 2.0.0

Parceler 1.1.6

I am trying to use the Parceler library with my POJO class that is also used for realm in my android app.

However, this line of code will crash

Bundle bundle = new Bundle(1);

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

This the error message:

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

I have declared the dependancies like this:

compile 'org.parceler:parceler:1.1.6'

apt 'org.parceler:parceler:1.1.6'

Is there any way to solve this issue?

This is my class that I am using

@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;

}

}

Many thanks in advance,

网友答案:

Found the answer if anyone else has the same issue:

@Parcel(implementations = {PersonRealmProxy.class},
        value = Parcel.Serialization.BEAN,
        analyze = {Person.class})
分享给朋友:
您可能感兴趣的文章:
随机阅读: