{"record":{"id":"21ad8471271be3e8","repo":"Tencent/tinker","slug":"fail-to-hack-resourceimpls-field","errorCode":null,"errorMessage":"Fail to hack resourceImpls field.","messagePattern":"Fail to hack resourceImpls field\\.","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcePatcher.java","lineNumber":313,"sourceCode":"                    if (!appInfo.sourceDir.equals(origResDir)) {\n                        continue;\n                    }\n\n                    if (Build.VERSION.SDK_INT >= 35) {\n                        mResDirField.set(resKey, externalResourceFile);\n                    }\n\n                    final WeakReference<Object> resValueRef = pair.getValue();\n                    final Object resourceImpl = resValueRef.get();\n                    if (resourceImpl != null) {\n                        if (implAssetsField == null) {\n                            implAssetsField = findField(resourceImpl, \"mAssets\");\n                        }\n                        implAssetsField.set(resourceImpl, newAssetManager);\n                    }\n                }\n            } catch (Throwable thr) {\n                throw new TinkerRuntimeException(\"Fail to hack resourceImpls field.\");\n            }\n        }\n\n        // Handle issues caused by WebView on Android N.\n        // Issue: On Android N, if an activity contains a webview, when screen rotates\n        // our resource patch may lost effects.\n        // for 5.x/6.x, we found Couldn't expand RemoteView for StatusBarNotification Exception\n        if (Build.VERSION.SDK_INT >= 24) {\n            try {\n                if (publicSourceDirField != null) {\n                    publicSourceDirField.set(context.getApplicationInfo(), externalResourceFile);\n                }\n            } catch (Throwable thr) {\n                ShareTinkerLog.printErrStackTrace(TAG, thr, \"fail to process publicSourceDirField field hack.\");\n            }\n        }\n\n        if (!checkResUpdate(context)) {","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcePatcher.java#L295-L331","documentation":"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.","triggerScenarios":"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.","commonSituations":"New Android releases (e.g. Q+) changing ResourcesImpl internals; OEM resource frameworks (dynamic color, theme engines) subclassing ResourcesImpl without an accessible mAssets.","solutions":["Update Tinker to the newest release with per-OS resource patching support.","If unfixable on that ROM, exclude resource patches for those devices (server-side patch targeting) or ship dex-only patches."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    TinkerResourcePatcher.monkeyPatchExistingResources(context, externalResourceFile);\n} catch (TinkerRuntimeException e) {\n    if (e.getMessage().contains(\"hack resourceImpls\")) {\n        // reflection unsupported on this ROM: proceed without resource patch\n    } else { throw e; }\n}","preventionTips":["Keep Tinker updated for new ResourcesImpl layouts each Android release.","Gate resource patches by device/OS allowlist from your patch server.","Make resource patches optional so dex fixes still ship on unsupported ROMs."],"tags":["android","resources","reflection","resourcesimpl","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}