解组类型代码和偏移值及其含义?

Unmarshalling type codes and offset value and their meaning?

我一直收到这个错误:-

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

即使在我完成此解决方案之后: 在我的 Android 应用程序中。

这可能是一个重复的问题,但我已经通过了各种建议的解决方案:

1.) 更改 proguard 配置文件。

2.) 检查读取和写入解析操作是否对相同的数据类型执行。

以及来自不同线程的许多其他解决方案,但这并没有解决我的问题。

主要是,有谁知道未知类型代码xxxx和偏移量yyyy是什么意思。我的意思是这两个值到底表示什么?

更新:-

我在代码中滚动,我发现这个异常基本上是从属于 android.os.ParcelreadValue() 函数抛出的,它接受 ClassLoaderloader 对象 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);
    }
}

所以这意味着,如果 type 在某些情况下没有得到匹配,那么代码会进入 default。 我还知道如果 loader 出现 null,那么代码将进入默认值。

所以,这意味着函数开头的 readInt() 以某种方式获得了与这些不同的价值,在同一个 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;

在我的情况下是 30。所以我仍然不清楚,如前所述,如果值 xxxx 与声明的值不同,如何确定它?

检查你的解析顺序,或者你可以使用android工作室插件。https://plugins.jetbrains.com/plugin/7332?pr=