1
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,

ant2009
  • 27,094
  • 154
  • 411
  • 609
  • 1
    Why do you need to do this? You shouldn't encode/decode realm objects as they are very particular in the ways they store data. If you have to send an object though an intent, you should only send the object's id, and fetch it again on the other activity. – jturolla Nov 03 '16 at 00:14

1 Answers1

0

Found the answer if anyone else has the same issue:

@Parcel(implementations = {PersonRealmProxy.class},
        value = Parcel.Serialization.BEAN,
        analyze = {Person.class})
ant2009
  • 27,094
  • 154
  • 411
  • 609