2

I have a class that implements Parcelable, which is throwing me a NoClassDefFoundError with class not found exception on some devices. Currently I have only gotten this error on Samsung Android devices. On Nexus 5, Nexus 4 and Android emulators it works as it should but not on Samsung for some reason. I have only tested this on the Samsung Remote Test Lab as I do not have a Samsung device for debugging.

Also the class in question is nothing special. A simple class with only longs, string and int written/read from the parcel. I checked that the order is the same when reading and writing. Additionally, the class is not referenced from a library.

ERROR   06-23 09:14:13.578  892 1507        Parcel  Class not found when unmarshalling: path.class

ERROR   06-23 09:14:13.578  892 1507        Parcel  Caused by: java.lang.NoClassDefFoundError: path/class

ERROR   06-23 09:14:13.578  892 1507        Parcel  Caused by: java.lang.ClassNotFoundException: Didn't find class "path.class" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Code for the parcelable part of the class.

public class Sprint implements Parcelable {

    private long mStartTime;
    private long mEndTime;
    private int mDaysInSprint;
    private String mSprintTitle;
    private int mId;

    private Sprint(Parcel source) {
        mStartTime = source.readLong();
        mEndTime = source.readLong();
        mDaysInSprint = source.readInt();
        mSprintTitle = source.readString();
        mId = source.readInt();
    }
    public static final Parcelable.Creator<Sprint> CREATOR = new Parcelable.Creator<Sprint>() {
        @Override
        public Sprint createFromParcel(Parcel source) {
            return new Sprint(source);
        }
        @Override
        public Sprint[] newArray(int size) {
            return new Sprint[size];
        }
    };

    @Override
    public int describeContents() {
        return hashCode();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeLong(mStartTime);
        dest.writeLong(mEndTime);
        dest.writeInt(mDaysInSprint);
        dest.writeString(mSprintTitle);
        dest.writeInt(mId);
    }
Max Meijer
  • 1,530
  • 1
  • 14
  • 23
tsj
  • 21
  • 2

1 Answers1

0

This error may cause because of API version compatibility. Please check and use latest version of API. Am not sure but as per my knowledge this is the reason

iffu
  • 331
  • 1
  • 4
  • 16