Tencent/tinker · error · DexException

Unexpected type: ${type}

Error message

Unexpected type: ${type}

What it means

Thrown by EncodedValueReader.skipValue() when the one-byte type tag of an encoded value is none of the known ENCODED_* constants (0x00–0x1e range: byte/short/char/int/long/float/double/string/type/field/method/enum/array/annotation/null/boolean). A type tag outside the dispatch table means the stream is misaligned or the dex is corrupt.

Source

Thrown at third-party/aosp-dexutils/src/main/java/com/tencent/tinker/android/dex/EncodedValueReader.java:297

        case ENCODED_ARRAY:
            for (int i = 0, size = readArray(); i < size; i++) {
                skipValue();
            }
            break;
        case ENCODED_ANNOTATION:
            for (int i = 0, size = readAnnotation(); i < size; i++) {
                readAnnotationName();
                skipValue();
            }
            break;
        case ENCODED_NULL:
            readNull();
            break;
        case ENCODED_BOOLEAN:
            readBoolean();
            break;
        default:
            throw new DexException("Unexpected type: " + Integer.toHexString(type));
        }
    }

    private void checkType(int expected) {
        if (peek() != expected) {
            throw new IllegalStateException(
                    String.format("Expected %x but was %x", expected, peek()));
        }
    }
}

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Dump the offending dex with a reference tool (dexdump/baksmali) — if it also chokes, the dex itself is malformed; regenerate it.
  2. Verify the reader's buffer position before the failing call — an earlier read of a different-width value typically causes the drift.
  3. Update this third-party aosp-dexutils copy from a newer AOSP revision if the dex comes from a newer format version.
Defensive patterns

Strategy: try-catch

Try / catch

try { reader.skipValue(); } catch (DexException e) { /* wrap with dex id + buffer position for triage */ throw new PatchParseException("bad encoded value in " + dexName + " @0x" + Integer.toHexString(reader.data.position()), e); }

Prevention

When it happens

Trigger: Calling skipValue()/readValue dispatch while iterating encoded_array or annotation data whose buffer position has drifted (an earlier value mis-read), or reading a hand-crafted/obfuscated dex with an invalid encoded_value type byte.

Common situations: Custom dex tooling built on Dex/EncodedValueReader hitting dexes produced by exotic obfuscators; version skew where a newer dex format introduces a tag this vendored copy does not know; buffer reuse where the reader was left mid-value.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/7b99c86e7ef51484. Report an issue: GitHub.