Tencent/tinker · error · TinkerRuntimeException

Fail to hack resourceImpls field.

Error message

Fail to hack resourceImpls field.

What it means

While iterating the discovered ResourcesImpl objects and replacing their mAssets field with the new AssetManager, any unexpected throwable is wrapped in TinkerRuntimeException('Fail to hack resourceImpls field.'). The reflection into ResourcesImpl.mAssets failing is the usual cause.

Source

Thrown at tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcePatcher.java:313

                    if (!appInfo.sourceDir.equals(origResDir)) {
                        continue;
                    }

                    if (Build.VERSION.SDK_INT >= 35) {
                        mResDirField.set(resKey, externalResourceFile);
                    }

                    final WeakReference<Object> resValueRef = pair.getValue();
                    final Object resourceImpl = resValueRef.get();
                    if (resourceImpl != null) {
                        if (implAssetsField == null) {
                            implAssetsField = findField(resourceImpl, "mAssets");
                        }
                        implAssetsField.set(resourceImpl, newAssetManager);
                    }
                }
            } catch (Throwable thr) {
                throw new TinkerRuntimeException("Fail to hack resourceImpls field.");
            }
        }

        // Handle issues caused by WebView on Android N.
        // Issue: On Android N, if an activity contains a webview, when screen rotates
        // our resource patch may lost effects.
        // for 5.x/6.x, we found Couldn't expand RemoteView for StatusBarNotification Exception
        if (Build.VERSION.SDK_INT >= 24) {
            try {
                if (publicSourceDirField != null) {
                    publicSourceDirField.set(context.getApplicationInfo(), externalResourceFile);
                }
            } catch (Throwable thr) {
                ShareTinkerLog.printErrStackTrace(TAG, thr, "fail to process publicSourceDirField field hack.");
            }
        }

        if (!checkResUpdate(context)) {

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Update Tinker to the newest release with per-OS resource patching support.
  2. If unfixable on that ROM, exclude resource patches for those devices (server-side patch targeting) or ship dex-only patches.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    TinkerResourcePatcher.monkeyPatchExistingResources(context, externalResourceFile);
} catch (TinkerRuntimeException e) {
    if (e.getMessage().contains("hack resourceImpls")) {
        // reflection unsupported on this ROM: proceed without resource patch
    } else { throw e; }
}

Prevention

When it happens

Trigger: findField(resourceImpl, "mAssets") or implAssetsField.set(...) throwing on frameworks where ResourcesImpl was refactored (field renamed/retyped), or where hidden-API restrictions block the field access.

Common situations: New Android releases (e.g. Q+) changing ResourcesImpl internals; OEM resource frameworks (dynamic color, theme engines) subclassing ResourcesImpl without an accessible mAssets.

Related errors


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