Tencent/tinker · error · TinkerRuntimeException
can't recognize dex mode:{}
Error message
can't recognize dex mode:{} What it means
ShareDexDiffPatchInfo parses each line of the patch's dex meta file; the third field of each line is the dex mode. Only 'jar' (ShareConstants.DEXMODE_JAR) and 'raw' (DEXMODE_RAW) are accepted; any other value throws TinkerRuntimeException("can't recognize dex mode:"). It indicates the patch package meta was generated by an incompatible/unknown tool version or was corrupted.
Source
Thrown at tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareDexDiffPatchInfo.java:69
this.path = path;
this.destMd5InDvm = destMd5InDvm;
this.destMd5InArt = destMd5InArt;
this.dexDiffMd5 = dexDiffMd5;
this.oldDexCrC = oldDexCrc;
this.newOrPatchedDexCrC = newOrPatchedDexCrC;
this.dexMode = dexMode;
if (dexMode.equals(ShareConstants.DEXMODE_JAR)) {
this.isJarMode = true;
if (SharePatchFileUtil.isRawDexFile(name)) {
realName = name + ShareConstants.JAR_SUFFIX;
} else {
realName = name;
}
} else if (dexMode.equals(ShareConstants.DEXMODE_RAW)) {
this.isJarMode = false;
this.realName = name;
} else {
throw new TinkerRuntimeException("can't recognize dex mode:" + dexMode);
}
}
public static void parseDexDiffPatchInfo(String meta, ArrayList<ShareDexDiffPatchInfo> dexList) {
if (meta == null || meta.length() == 0) {
return;
}
String[] lines = meta.split("\n");
for (final String line : lines) {
if (line == null || line.length() <= 0) {
continue;
}
final String[] kv = line.split(",", 8);
if (kv == null || kv.length < 8) {
continue;
}
// keyView on GitHub (pinned to 1b7ea02c23)
Solutions
- Match versions: use the tinker gradle plugin release that corresponds to the tinker-android-lib in the app.
- Rebuild the patch with the standard build pipeline and do not edit any *-meta.txt inside the package.
- Verify the patch package with ShareTinkerInternals / patch version checks before calling tryLoadPatch, and reject patches whose meta format is unknown.
- Confirm the dexMode string in dex_meta.txt is exactly 'jar' or 'raw' (no whitespace, correct casing).
Example fix
// before
String dexMode = fields[2]; // may contain 'Jar ' or garbage
// after
String dexMode = fields[2].trim().toLowerCase();
if (!DEXMODE_JAR.equals(dexMode) && !DEXMODE_RAW.equals(dexMode)) {
throw new TinkerRuntimeException("can't recognize dex mode:" + dexMode);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate dex meta lines before constructing ShareDexDiffPatchInfo
for (String line : meta.split("\n")) {
String[] f = line.split(",", -1);
if (f.length < 9) continue;
String mode = f[2].trim();
if (!"jar".equals(mode) && !"raw".equals(mode)) {
// reject patch package: unknown meta format
}
} Try / catch
try {
ShareDexDiffPatchInfo.parseDexDiffPatchInfo(meta, dexList);
} catch (TinkerRuntimeException e) {
// patch package incompatible with this loader version: reject and report version pair
} Prevention
- Pin tinker gradle plugin and tinker-android-lib to matching versions in CI.
- Never modify meta files inside a built patch package.
- Smoke-test each patch on a device before full rollout.
When it happens
Trigger: Constructing ShareDexDiffPatchInfo from a meta line whose dexMode column is neither 'jar' nor 'raw' — typically while tinker-android-loader parses assets/dex_meta.txt during patch load or verify.
Common situations: Patch built with a tinker-patch-gradle-plugin version whose meta format does not match the loader version in the app; hand-edited or truncated dex_meta.txt; old patches (raw dex mode) loaded by a loader expecting jar mode or vice versa; mixed plugin/gradle versions between build and runtime.
Related errors
- patch %s extract failed (%s).
- can't recognize zip dex format file:%s
- patch dex file directory not found, warning why the path is
- patch dex file not found, but path is null!!!!
- createDelegate failed
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/ac8630e49f976458.
Report an issue: GitHub.