Mrigank
Mrigank

Reputation: 532

Unmarshalling type codes and offset value and their meaning?

I have been getting this error:-

java.lang.RuntimeException: Parcel android.os.Parcel@41a2f780: Unmarshalling unknown type code 30 at offset 8804

even after I have gone through this solution : https://stackoverflow.com/a/21380449/2492278 in my Android app.

This may be a duplicate question, but I have gone through various solutions suggesting:

1.) Changing in the proguard conf file.

2.) Checking that read and write parse operations are performed on same data types.

And many other solutions from various threads, but that is not solving my problem.

Mainly, does anyone know what is meant by the unknown type code xxxx and offset yyyy. I mean what exactly those two values signify?

Update:-

I was scrolling in the code and I found that this Exception basically gets thrown from readValue() function belonging to android.os.Parcel which accepts loader object of ClassLoader class.

public final Object readValue(ClassLoader loader) {
        int type = readInt();
    switch (type) {
    case VAL_NULL:
        return null;

    case VAL_STRING:
        return readString();

    case VAL_INTEGER:
        return readInt();

    case VAL_MAP:
        return readHashMap(loader);

    case VAL_PARCELABLE:
        return readParcelable(loader);

    case VAL_SHORT:
        return (short) readInt();

    case VAL_LONG:
        return readLong();

    case VAL_FLOAT:
        return readFloat();

    case VAL_DOUBLE:
        return readDouble();

    case VAL_BOOLEAN:
        return readInt() == 1;

    case VAL_CHARSEQUENCE:
        return readCharSequence();

    case VAL_LIST:
        return readArrayList(loader);

    case VAL_BOOLEANARRAY:
        return createBooleanArray();        

    case VAL_BYTEARRAY:
        return createByteArray();

    case VAL_STRINGARRAY:
        return readStringArray();

    case VAL_CHARSEQUENCEARRAY:
        return readCharSequenceArray();

    case VAL_IBINDER:
        return readStrongBinder();

    case VAL_OBJECTARRAY:
        return readArray(loader);

    case VAL_INTARRAY:
        return createIntArray();

    case VAL_LONGARRAY:
        return createLongArray();

    case VAL_BYTE:
        return readByte();

    case VAL_SERIALIZABLE:
        return readSerializable(loader);

    case VAL_PARCELABLEARRAY:
        return readParcelableArray(loader);

    case VAL_SPARSEARRAY:
        return readSparseArray(loader);

    case VAL_SPARSEBOOLEANARRAY:
        return readSparseBooleanArray();

    case VAL_BUNDLE:
        return readBundle(loader); // loading will be deferred

    case VAL_PERSISTABLEBUNDLE:
        return readPersistableBundle(loader);

    case VAL_SIZE:
        return readSize();

    case VAL_SIZEF:
        return readSizeF();

    default:
        int off = dataPosition() - 4;
        throw new RuntimeException(
            "Parcel " + this + ": Unmarshalling unknown type code " + type + " at offset " + off);
    }
}

So this means, if somehow type doesn't get matched in the cases, then code goes into the default. Also I got to know that if loader comes null,then the code goes into the default.

So, that means that somehow readInt() in the function beginning is getting value apart from these,declared in same Parcel class:-

    private static final int VAL_NULL = -1;
    private static final int VAL_STRING = 0;
    private static final int VAL_INTEGER = 1;
    private static final int VAL_MAP = 2;
    private static final int VAL_BUNDLE = 3;
    private static final int VAL_PARCELABLE = 4;
    private static final int VAL_SHORT = 5;
    private static final int VAL_LONG = 6;
    private static final int VAL_FLOAT = 7;
    private static final int VAL_DOUBLE = 8;
    private static final int VAL_BOOLEAN = 9;
    private static final int VAL_CHARSEQUENCE = 10;
    private static final int VAL_LIST  = 11;
    private static final int VAL_SPARSEARRAY = 12;
    private static final int VAL_BYTEARRAY = 13;
    private static final int VAL_STRINGARRAY = 14;
    private static final int VAL_IBINDER = 15;
    private static final int VAL_PARCELABLEARRAY = 16;
    private static final int VAL_OBJECTARRAY = 17;
    private static final int VAL_INTARRAY = 18;
    private static final int VAL_LONGARRAY = 19;
    private static final int VAL_BYTE = 20;
    private static final int VAL_SERIALIZABLE = 21;
    private static final int VAL_SPARSEBOOLEANARRAY = 22;
    private static final int VAL_BOOLEANARRAY = 23;
    private static final int VAL_CHARSEQUENCEARRAY = 24;
    private static final int VAL_PERSISTABLEBUNDLE = 25;
    private static final int VAL_SIZE = 26;
    private static final int VAL_SIZEF = 27;

and in my case 30. So that still remains unclear to me, as asked previously, how the value xxxx is determined if its apart from the declared ones?

Upvotes: 4

Views: 218

Answers (1)

DivyaSourabh
DivyaSourabh

Reputation: 86

Check your sequence of parsing, or you can use android studio plug in.https://plugins.jetbrains.com/plugin/7332?pr=

Upvotes: 2

Related Questions