Tencent/tinker · error · TinkerRuntimeException
patch dex file directory not found, warning why the path is
Error message
patch dex file directory not found, warning why the path is null!!!!
What it means
Thrown from TinkerLoadResult while handling ERROR_LOAD_PATCH_VERSION_DEX_DIRECTORY_NOT_EXIST: the loader reported that the patch's dex directory is missing, but the computed dexDirectory File is null. The comment in source ('should be not here') marks it as a should-never-happen defensive branch; hitting it means the load result intent and the locally reconstructed patch paths disagree — an internal state inconsistency rather than a user-input error.
Source
Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/tinker/TinkerLoadResult.java:201
ShareConstants.TYPE_PATCH_FILE, false);
break;
case ShareConstants.ERROR_LOAD_PATCH_PACKAGE_CHECK_FAIL:
ShareTinkerLog.i(TAG, "patch package check fail");
if (patchVersionFile == null) {
throw new TinkerRuntimeException("error patch package check fail , but file is null");
}
int errorCode = intentResult.getIntExtra(ShareIntentUtil.INTENT_PATCH_PACKAGE_PATCH_CHECK, ShareConstants.ERROR_LOAD_GET_INTENT_FAIL);
tinker.getLoadReporter().onLoadPackageCheckFail(patchVersionFile, errorCode);
break;
case ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_DIRECTORY_NOT_EXIST:
if (dexDirectory != null) {
ShareTinkerLog.e(TAG, "patch dex file directory not found:%s", dexDirectory.getAbsolutePath());
tinker.getLoadReporter().onLoadFileNotFound(dexDirectory,
ShareConstants.TYPE_DEX, true);
} else {
//should be not here
ShareTinkerLog.e(TAG, "patch dex file directory not found, warning why the path is null!!!!");
throw new TinkerRuntimeException("patch dex file directory not found, warning why the path is null!!!!");
}
break;
case ShareConstants.ERROR_LOAD_PATCH_VERSION_DEX_FILE_NOT_EXIST:
String dexPath = ShareIntentUtil.getStringExtra(intentResult,
ShareIntentUtil.INTENT_PATCH_MISSING_DEX_PATH);
if (dexPath != null) {
//we only pass one missing file
ShareTinkerLog.e(TAG, "patch dex file not found:%s", dexPath);
tinker.getLoadReporter().onLoadFileNotFound(new File(dexPath),
ShareConstants.TYPE_DEX, false);
} 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;View on GitHub (pinned to 1b7ea02c23)
Solutions
- Call Tinker.with(context).cleanPatch() to remove the inconsistent patch state, then re-apply the patch.
- Reproduce and inspect /data/data/<pkg>/tinker/: check that patch.info and the version directory match; if not, wipe via cleanPatch.
- Make sure only official Tinker APIs (TinkerInstaller) manage the tinker directory; never delete or move files inside it manually.
- Align the tinker Android library and gradle plugin versions in your build.
Example fix
// after catching this in a global handler
catch (TinkerRuntimeException e) {
if (e.getMessage().contains("dex file directory not found")) {
Tinker.with(appContext).cleanPatch();
}
} Defensive patterns
Strategy: try-catch
Validate before calling
Tinker tinker = Tinker.with(context);
if (tinker.isTinkerLoaded()) {
File dexDir = new File(tinker.getTinkerLoadResultIfPresent().patchVersionDirectory, "dex");
if (!dexDir.isDirectory()) tinker.cleanPatch();
} Try / catch
catch (TinkerRuntimeException e) {
if (e.getMessage().contains("dex file directory not found")) {
Tinker.with(app).cleanPatch();
} else throw e;
} Prevention
- Let only Tinker APIs manage /tinker directories
- Re-apply patches after cleanPatch instead of retrying loads on broken state
When it happens
Trigger: The loader returns ERROR_LOAD_PATCH_VERSION_DEX_DIRECTORY_NOT_EXIST while dexDirectory (built from the patch version directory) is null — i.e. patch info/JSON metadata exists enough to attempt a load but the version directory path could not be derived. Happens when the patch metadata is corrupted or the tinker directory layout was altered externally.
Common situations: Corrupted patch info file (partially written JSON); tinker directory structure tampered with by device cleaners, Xposed-style tools, or ADB; running a patch built by a mismatched tinker gradle plugin version that writes a different layout.
Related errors
- patch %s extract failed (%s).
- patch dex file not found, but path is null!!!!
- patch lib file directory not found, warning why the path is
- patch resource file directory not found, warning why the pat
- patch resource file not found, warning why the path is null!
AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14).
Data as JSON: /api/errors/34fc579d4fab5eb7.
Report an issue: GitHub.