{"record":{"id":"0be86660cc3f6361","repo":"Tencent/tinker","slug":"resource-references-is-null","errorCode":null,"errorMessage":"resource references is null","messagePattern":"resource references is null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcePatcher.java","lineNumber":167,"sourceCode":"                final Field mResourceReferences = findField(resourcesManagerClass, \"mResourceReferences\");\n                references = (Collection<WeakReference<Resources>>) mResourceReferences.get(resourcesManager);\n\n                try {\n                    final Field mResourceImplsField = findField(resourcesManagerClass, \"mResourceImpls\");\n                    resourceImpls = (Map<Object, WeakReference<Object>>) mResourceImplsField.get(resourcesManager);\n                } catch (Throwable ignored) {\n                    resourceImpls = null;\n                }\n            }\n        } else {\n            final Field fMActiveResources = findField(activityThread, \"mActiveResources\");\n            final HashMap<?, WeakReference<Resources>> activeResources7 =\n                    (HashMap<?, WeakReference<Resources>>) fMActiveResources.get(currentActivityThread);\n            references = activeResources7.values();\n        }\n        // check resource\n        if (references == null) {\n            throw new IllegalStateException(\"resource references is null\");\n        }\n\n        final Resources resources = context.getResources();\n\n        // fix jianGuo pro has private field 'mAssets' with Resource\n        // try use mResourcesImpl first\n        if (SDK_INT >= 24) {\n            try {\n                // N moved the mAssets inside an mResourcesImpl field\n                resourcesImplFiled = findField(resources, \"mResourcesImpl\");\n            } catch (Throwable ignore) {\n                // for safety\n                assetsFiled = findField(resources, \"mAssets\");\n            }\n        } else {\n            assetsFiled = findField(resources, \"mAssets\");\n        }\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader/src/main/java/com/tencent/tinker/loader/TinkerResourcePatcher.java#L149-L185","documentation":"To inject patched resources, Tinker enumerates every live Resources instance via ActivityThread's internal registry (mResourceImpls on N+, mActiveResources on older versions). This IllegalStateException means both lookups yielded null, so there is no known set of Resources objects to patch and the resource patch cannot be applied.","triggerScenarios":"MonkeyPatchResourcePatcher running on a framework where ActivityThread's resource-registry field was renamed, removed, or typed differently by the OEM; also when reflection to ActivityThread itself failed earlier and the fallback path also found nothing.","commonSituations":"Non-AOSP or heavily modified ROMs; preview/beta Android versions whose ActivityThread internals differ; devices where hidden-API restrictions block reading these fields.","solutions":["Update Tinker to a version supporting the device's Android release.","Reproduce on the exact device/ROM, dump ActivityThread fields, and report to Tinker maintainers.","Disable resource patching (tinker not configured for RES, or only ship DEX patches) if the app can tolerate missing resource fixes on that ROM."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight on the target device before enabling resource patches\ntry {\n    Object at = ShareReflectUtil.getActivityThread(context, null);\n    ShareReflectUtil.findField(at, SDK_INT >= 24 ? \"mResourcesManager\" : \"mActiveResources\");\n} catch (Throwable t) {\n    disableResourcePatchForThisDevice();\n}","typeGuard":null,"tryCatchPattern":"try {\n    TinkerResourcePatcher.monkeyPatchExistingResources(context, externalResourceFile);\n} catch (TinkerRuntimeException e) {\n    // resource injection unsupported here: continue with dex-only patch\n    Log.w(TAG, \"resource patch skipped: \" + e.getMessage());\n}","preventionTips":["Ship resource patches only to device/OS combinations validated in QA.","Update Tinker promptly when adopting new Android versions.","Design the app to tolerate missing resource patches (dex patch still applies)."],"tags":["android","resources","reflection","activitythread","tinker"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}