Tencent/tinker · error · TinkerRuntimeException

patch dex opt file not found, but path is null!!!!

Error message

patch dex opt file not found, but path is null!!!!

What it means

Defensive TinkerRuntimeException from the ERROR_LOAD_PATCH_VERSION_DEX_OPT_FILE_NOT_EXIST branch: the loader says an optimized-dex (odex/dex opt) artifact is missing, but INTENT_PATCH_MISSING_DEX_PATH was not supplied, so there is no path to report. It marks an inconsistency between the loader's error result and the data TinkerLoadResult can see.

Source

Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/TinkerLoadResult.java:231

                } else {
                    ShareTinkerLog.e(TAG, "patch dex file not found, but path is null!!!!");
                    throw new TinkerRuntimeException("patch dex file not found, but path is null!!!!");
                    // tinker.getLoadReporter().onLoadFileNotFound(null,
                    //     ShareConstants.TYPE_DEX, false);
                }
                break;
            case ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_OPT_FILE_NOT_EXIST:
                String dexOptPath = ShareIntentUtil.getStringExtra(intentResult,
                    ShareIntentUtil.INTENT_PATCH_MISSING_DEX_PATH);
                if (dexOptPath != null) {
                    //we only pass one missing file
                    ShareTinkerLog.e(TAG, "patch dex opt file not found:%s", dexOptPath);
                    tinker.getLoadReporter().onLoadFileNotFound(new File(dexOptPath),
                        ShareConstants.TYPE_DEX_OPT, false);

                } else {
                    ShareTinkerLog.e(TAG, "patch dex opt file not found, but path is null!!!!");
                    throw new TinkerRuntimeException("patch dex opt file not found, but path is null!!!!");
                    // tinker.getLoadReporter().onLoadFileNotFound(null,
                    //     ShareConstants.TYPE_DEX, false);
                }
                break;
            case ShareConstants.ERROR_LOAD_PATCH_VERSION_LIB_DIRECTORY_NOT_EXIST:
                if (patchVersionDirectory != null) {
                    ShareTinkerLog.e(TAG, "patch lib file directory not found:%s", libraryDirectory.getAbsolutePath());
                    tinker.getLoadReporter().onLoadFileNotFound(libraryDirectory,
                        ShareConstants.TYPE_LIBRARY, true);
                } else {
                    //should be not here
                    ShareTinkerLog.e(TAG, "patch lib file directory not found, warning why the path is null!!!!");
                    throw new TinkerRuntimeException("patch lib file directory not found, warning why the path is null!!!!");

                    // tinker.getLoadReporter().onLoadFileNotFound(null,
                    //     ShareConstants.TYPE_LIBRARY, true);
                }

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. cleanPatch() then reinstall the patch so odex artifacts regenerate on next load.
  2. Keep tinker components on one consistent version.
  3. If it recurs after every OTA, treat onLoadFileNotFound(TYPE_DEX_OPT) in your LoadReporter as a signal to roll back the patch.
  4. Preserve the tinker odex directory from cleanup tools.
Defensive patterns

Strategy: try-catch

Try / catch

catch (TinkerRuntimeException e) {
    if (e.getMessage() != null && e.getMessage().contains("dex opt file not found")) {
        Tinker.with(app).cleanPatch();
    } else throw e;
}

Prevention

When it happens

Trigger: Result code ERROR_LOAD_PATCH_VERSION_DEX_OPT_FILE_NOT_EXIST arrives with a null INTENT_PATCH_MISSING_DEX_PATH extra. Realistic when the odex file was removed from the app's odex directory (e.g. by Android's dexopt cleanup or a full-dexopt re-run) while the versioned path extra got lost.

Common situations: Device storage pressure triggering ART to clear odex files; app moved to/from adopted storage; OS upgrade forcing re-dexopt; loader/library version mismatch dropping the extra.

Related errors


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