Tencent/tinker · error · TinkerRuntimeException

patch resource file directory not found, warning why the pat

Error message

patch resource file directory not found, warning why the path is null!!!!

What it means

Defensive throw in the ERROR_LOAD_PATCH_VERSION_RESOURCE_DIRECTORY_NOT_EXIST branch: the loader reports the patch resource directory missing, but patchVersionDirectory is null, so Tinker cannot build the onLoadFileNotFound(resourceDirectory, TYPE_RESOURCE, true) callback and instead crashes with TinkerRuntimeException. Source comment marks it 'should be not here' — an invariant break between load result and local state.

Source

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

                } else {
                    ShareTinkerLog.e(TAG, "patch dex file md5 is mismatch: %s", mismatchPath);
                    tinker.getLoadReporter().onLoadFileMd5Mismatch(new File(mismatchPath),
                        ShareConstants.TYPE_DEX);
                }
                break;
            case ShareConstants.ERROR_LOAD_PATCH_REWRITE_PATCH_INFO_FAIL:
                ShareTinkerLog.i(TAG, "rewrite patch info file corrupted");
                tinker.getLoadReporter().onLoadPatchInfoCorrupted(oldVersion, newVersion, patchInfoFile);
                break;
            case ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_DIRECTORY_NOT_EXIST:
                if (patchVersionDirectory != null) {
                    ShareTinkerLog.e(TAG, "patch resource file directory not found:%s", resourceDirectory.getAbsolutePath());
                    tinker.getLoadReporter().onLoadFileNotFound(resourceDirectory,
                        ShareConstants.TYPE_RESOURCE, true);
                } else {
                    //should be not here
                    ShareTinkerLog.e(TAG, "patch resource file directory not found, warning why the path is null!!!!");
                    throw new TinkerRuntimeException("patch resource file directory not found, warning why the path is null!!!!");
                }
                break;
            case ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_FILE_NOT_EXIST:
                if (patchVersionDirectory != null) {
                    ShareTinkerLog.e(TAG, "patch resource file not found:%s", resourceFile.getAbsolutePath());
                    tinker.getLoadReporter().onLoadFileNotFound(resourceFile,
                        ShareConstants.TYPE_RESOURCE, false);
                } else {
                    //should be not here
                    ShareTinkerLog.e(TAG, "patch resource file not found, warning why the path is null!!!!");
                    throw new TinkerRuntimeException("patch resource file not found, warning why the path is null!!!!");
                }
                break;
            case ShareConstants.ERROR_LOAD_PATCH_VERSION_RESOURCE_MD5_MISMATCH:
                if (resourceFile == null) {
                    ShareTinkerLog.e(TAG, "resource file md5 mismatch, but patch resource file not found!");
                    throw new TinkerRuntimeException("resource file md5 mismatch, but patch resource file not found!");
                }

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. cleanPatch() and re-apply.
  2. Ensure resource patches are enabled (tinkerEnableResourcePatch / SUPPORT resources flag) consistently between build and runtime.
  3. Keep tinker directory untouched by external tools.
  4. Match gradle plugin and runtime library versions.
Defensive patterns

Strategy: try-catch

Validate before calling

if (tinker.isTinkerEnabled() && tinker.getTinkerLoadResultIfPresent().patchVersionDirectory == null
        && tinker.isTinkerLoaded()) {
    tinker.cleanPatch();
}

Try / catch

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

Prevention

When it happens

Trigger: Result code ERROR_LOAD_PATCH_VERSION_RESOURCE_DIRECTORY_NOT_EXIST while patchVersionDirectory is null — the version directory could not be derived from patch info even though a load was attempted.

Common situations: Corrupt patch info file; tinker directory manipulated externally; resource patch applied by a plugin version writing a different layout than the loader expects.

Related errors


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