Tencent/tinker · error · IllegalArgumentException

No such map item: ${type}

Error message

No such map item: ${type}

What it means

Thrown by the loop-based getSection(short type) (used by readMap) when a map_list entry's type code matches none of the Section instances in the table. Functionally the same failure as the switch-based variant at line 150, reached through the map-reading path.

Source

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

        dataOff = header.byteCount
                + stringIds.byteCount
                + typeIds.byteCount
                + protoIds.byteCount
                + fieldIds.byteCount
                + methodIds.byteCount
                + classDefs.byteCount;

        dataSize = fileSize - dataOff;
    }

    private Section getSection(short type) {
        for (Section section : sections) {
            if (section.type == type) {
                return section;
            }
        }
        throw new IllegalArgumentException("No such map item: " + type);
    }

    public void writeHeader(Dex.Section out) throws IOException {
        out.write(DexFormat.apiToMagic(api).getBytes("UTF-8"));
        out.writeInt(checksum);
        out.write(signature);
        out.writeInt(fileSize);
        out.writeInt(SizeOf.HEADER_ITEM);
        out.writeInt(DexFormat.ENDIAN_TAG);
        out.writeInt(linkSize);
        out.writeInt(linkOff);
        out.writeInt(mapList.off);
        out.writeInt(stringIds.size);
        out.writeInt((stringIds.exists() ? stringIds.off : 0));
        out.writeInt(typeIds.size);
        out.writeInt((typeIds.exists() ? typeIds.off : 0));
        out.writeInt(protoIds.size);
        out.writeInt((protoIds.exists() ? protoIds.off : 0));

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Upgrade the third-party aosp-dexutils/tinker dependency to a version whose Section table includes the newer map item types.
  2. Lower the dex format version at generation time (d8 `--min-api 25`/equivalent avoids emitting call-site/method-handle items) so old parsers cope.
  3. Diagnose with dexdump to see the exact unknown type code and where it comes from.
Defensive patterns

Strategy: validation

Validate before calling

// pre-scan map_list types before TableOfContents.readFrom
int mapOff = headerBuf.getInt(52);
// parse map entries; if any type in {0x0007, 0x0008} (callsite/method_handle) and library is old, route to upgraded toolchain

Try / catch

catch (IllegalArgumentException e) with 'No such map item' -> version-skew: upgrade dependency or lower emitted dex format version

Prevention

When it happens

Trigger: readMap encounters a map item type constant this library's Section array doesn't define — e.g. TYPE_CALLSITE_ID (0x0007) or TYPE_METHOD_HANDLE (0x0008) from dex format 038 in an older vendored copy — or garbage type bytes.

Common situations: Tinker patch builds consuming modern dexes (Kotlin, desugared lambdas produce method handles/call sites) with an outdated aosp-dexutils dependency; corrupted map regions.

Related errors


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