{"record":{"id":"6d11820f568c8cdb","repo":"Tencent/tinker","slug":"field-not-found-in","errorCode":null,"errorMessage":"Field {} not found in {}","messagePattern":"Field (.+?) not found in (.+?)","errorType":"exception","errorClass":"NoSuchFieldException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/ShareReflectUtil.java","lineNumber":55,"sourceCode":"     * @return a field object\n     * @throws NoSuchFieldException if the field cannot be located\n     */\n    public static Field findField(Object instance, String name) throws NoSuchFieldException {\n        for (Class<?> clazz = instance.getClass(); clazz != null; clazz = clazz.getSuperclass()) {\n            try {\n                Field field = clazz.getDeclaredField(name);\n\n                if (!field.isAccessible()) {\n                    field.setAccessible(true);\n                }\n\n                return field;\n            } catch (NoSuchFieldException e) {\n                // ignore and search next\n            }\n        }\n\n        throw new NoSuchFieldException(\"Field \" + name + \" not found in \" + instance.getClass());\n    }\n\n    public static Field findField(Class<?> originClazz, String name) throws NoSuchFieldException {\n        for (Class<?> clazz = originClazz; clazz != null; clazz = clazz.getSuperclass()) {\n            try {\n                Field field = clazz.getDeclaredField(name);\n\n                if (!field.isAccessible()) {\n                    field.setAccessible(true);\n                }\n\n                return field;\n            } catch (NoSuchFieldException e) {\n                // ignore and search next\n            }\n        }\n\n        throw new NoSuchFieldException(\"Field \" + name + \" not found in \" + originClazz);","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-loader-no-op/src/main/java/com/tencent/tinker/loader/shareutil/ShareReflectUtil.java#L37-L73","documentation":"ShareReflectUtil.findField(Object instance, String name) walks instance.getClass() up the superclass chain calling getDeclaredField; if no class in the hierarchy declares the field it throws NoSuchFieldException('Field <name> not found in <instance.getClass()>'). Note the message reports the instance's concrete class, not each class searched. This error means framework internals the code depends on are absent or renamed on this device.","triggerScenarios":"Reflecting over Android framework internals whose name differs per OEM or API level (e.g. PathClassLoader fields across 4.x-13); passing an instance whose runtime class is a subclass/proxy that hides the expected hierarchy; proguard renaming app fields that the lookup expected.","commonSituations":"New Android releases renaming/repackaging internal ClassLoader members; OEM-skinned frameworks moving fields; security-hardened ROMs; code copied from another tinker version targeting a different field set.","solutions":["Identify the field name and target class at the call site and check the AOSP source for the device's Android version to get the correct name.","Upgrade tinker — version-gated reflection tables (V14/V19/V23/... classes) are maintained precisely for this.","Add the missing-field case to a fallback chain: try several known field names before giving up.","If the field belongs to your own classes, fix proguard rules so the name survives obfuscation."],"exampleFix":"// before\nField f = ShareReflectUtil.findField(classLoader, \"pathList\");\n\n// after\nField f;\ntry {\n    f = ShareReflectUtil.findField(classLoader, \"pathList\");\n} catch (NoSuchFieldException e) {\n    throw new IllegalStateException(\"Unsupported ClassLoader impl: \" + classLoader.getClass(), e);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { f = ShareReflectUtil.findField(instance, name); } catch (NoSuchFieldException e) { throw new UnsupportedOperationException('unsupported device framework', e); }","preventionTips":["Version-gate framework reflection by Build.VERSION.SDK_INT.","Enumerate declared fields at startup on unknown devices to build a compatibility map.","Upgrade tinker rather than hardcoding framework field names yourself."],"tags":["reflection","compatibility","android-framework"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}