How to fix Unmarshalling unknown type code XXX at offset YYY in Android? How to fix Unmarshalling unknown type code XXX at offset YYY in Android? android android

How to fix Unmarshalling unknown type code XXX at offset YYY in Android?


There's some rules for write and read parcelables.

1- Be careful about type mismatch. If you write int, don't try to read long etc.

2- Be careful about order of writes and reads. Objects must be at the same sort order when reading and writing.

Both of these can cause "Unmarshalling unknown type code".


If a type of List is added, it should be:

@Override    public void writeToParcel(Parcel dest, int flags) {        super.writeToParcel(dest, flags);        dest.writeList(this.mList);

and unparcel it using the class type like this:

protected MyClass(Parcel in) {        super(in);        this.mList = new ArrayList<>();        in.readList(this.mList, MyRequiredClass.class.getClassLoader());