{"record":{"id":"ac8630e49f976458","repo":"Tencent/tinker","slug":"can-t-recognize-dex-mode-ac8630","errorCode":null,"errorMessage":"can't recognize dex mode:{}","messagePattern":"can't recognize dex mode:(.+?)","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareDexDiffPatchInfo.java","lineNumber":69,"sourceCode":"        this.path = path;\n        this.destMd5InDvm = destMd5InDvm;\n        this.destMd5InArt = destMd5InArt;\n        this.dexDiffMd5 = dexDiffMd5;\n        this.oldDexCrC = oldDexCrc;\n        this.newOrPatchedDexCrC = newOrPatchedDexCrC;\n        this.dexMode = dexMode;\n        if (dexMode.equals(ShareConstants.DEXMODE_JAR)) {\n            this.isJarMode = true;\n            if (SharePatchFileUtil.isRawDexFile(name)) {\n                realName = name + ShareConstants.JAR_SUFFIX;\n            } else {\n                realName = name;\n            }\n        } else if (dexMode.equals(ShareConstants.DEXMODE_RAW)) {\n            this.isJarMode = false;\n            this.realName = name;\n        } else {\n            throw new TinkerRuntimeException(\"can't recognize dex mode:\" + dexMode);\n        }\n    }\n\n    public static void parseDexDiffPatchInfo(String meta, ArrayList<ShareDexDiffPatchInfo> dexList) {\n        if (meta == null || meta.length() == 0) {\n            return;\n        }\n        String[] lines = meta.split(\"\\n\");\n        for (final String line : lines) {\n            if (line == null || line.length() <= 0) {\n                continue;\n            }\n            final String[] kv = line.split(\",\", 8);\n            if (kv == null || kv.length < 8) {\n                continue;\n            }\n\n            // key","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/shareutil/ShareDexDiffPatchInfo.java#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":"// before\nString dexMode = fields[2]; // may contain 'Jar ' or garbage\n// after\nString dexMode = fields[2].trim().toLowerCase();\nif (!DEXMODE_JAR.equals(dexMode) && !DEXMODE_RAW.equals(dexMode)) {\n    throw new TinkerRuntimeException(\"can't recognize dex mode:\" + dexMode);\n}","handlingStrategy":"validation","validationCode":"// Validate dex meta lines before constructing ShareDexDiffPatchInfo\nfor (String line : meta.split(\"\\n\")) {\n    String[] f = line.split(\",\", -1);\n    if (f.length < 9) continue;\n    String mode = f[2].trim();\n    if (!\"jar\".equals(mode) && !\"raw\".equals(mode)) {\n        // reject patch package: unknown meta format\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    ShareDexDiffPatchInfo.parseDexDiffPatchInfo(meta, dexList);\n} catch (TinkerRuntimeException e) {\n    // patch package incompatible with this loader version: reject and report version pair\n}","preventionTips":["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."],"tags":["android","tinker","dex","patch-meta","version-mismatch"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}