Tencent/tinker · error · ExceptionWithContext

Invalid debug item type:

Error message

Invalid debug item type: 

What it means

ExceptionWithContext thrown when converting debug items to builder form: a debug item type (opcode) in the dex's debug info stream is not one of the known types (line number, source file, epilogue begin, etc.). The dexlib2 version bundled with Tinker cannot interpret it.

Source

Thrown at tinker-build/tinker-patch-lib/src/main/java/org/jf/dexlib2/builder/BuilderMutableMethodImplementation.java:1126

                RestartLocal restartLocal = (RestartLocal) debugItem;
                return new BuilderRestartLocal(restartLocal.getRegister());
            }
            case DebugItemType.PROLOGUE_END:
                return new BuilderPrologueEnd();
            case DebugItemType.EPILOGUE_BEGIN:
                return new BuilderEpilogueBegin();
            case DebugItemType.LINE_NUMBER: {
                LineNumber lineNumber = (LineNumber) debugItem;
                return new BuilderLineNumber(lineNumber.getLineNumber());
            }
            case DebugItemType.SET_SOURCE_FILE: {
                SetSourceFile setSourceFile = (SetSourceFile) debugItem;
                return new BuilderSetSourceFile(
                        (StringReference) convertReference(setSourceFile.getSourceFileReference())
                );
            }
            default:
                throw new ExceptionWithContext("Invalid debug item type: " + debugItem.getDebugItemType());
        }
    }
}

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Upgrade Tinker so its dexlib2 knows the newer debug item types
  2. Disable debug info in the offending build (minify with debug info stripped, or -g:none style options) and regenerate the patch
  3. Rebuild the base apk with a stable toolchain version and re-diff
Defensive patterns

Strategy: try-catch

Try / catch

try {
    // dex rewrite involving debug info
} catch (org.jf.util.ExceptionWithContext e) {
    if (String.valueOf(e.getMessage()).startsWith("Invalid debug item type")) {
        // strip debug info from the offending build or upgrade Tinker
    } else { throw e; }
}

Prevention

When it happens

Trigger: A dex debug info item whose type byte is outside the handled DebugItemType constants, encountered while Tinker rewrites instructions and rebuilds debug info.

Common situations: Dex emitted by newer compilers/toolchains introducing new debug opcodes; obfuscators stripping or rewriting debug info in non-standard ways; corrupted debug sections.

Related errors


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