{"record":{"id":"a0df8cd20e249ec2","repo":"DrKLO/Telegram","slug":"positiondescription-unable-to-find-layoutmanage","errorCode":null,"errorMessage":"{positionDescription}: Unable to find LayoutManager {className}","messagePattern":"(.+?): Unable to find LayoutManager (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java","lineNumber":871,"sourceCode":"                    Constructor<? extends LayoutManager> constructor;\n                    Object[] constructorArgs = null;\n                    try {\n                        constructor = layoutManagerClass\n                                .getConstructor(LAYOUT_MANAGER_CONSTRUCTOR_SIGNATURE);\n                        constructorArgs = new Object[]{context, attrs, defStyleAttr, defStyleRes};\n                    } catch (NoSuchMethodException e) {\n                        try {\n                            constructor = layoutManagerClass.getConstructor();\n                        } catch (NoSuchMethodException e1) {\n                            e1.initCause(e);\n                            throw new IllegalStateException(attrs.getPositionDescription()\n                                    + \": Error creating LayoutManager \" + className, e1);\n                        }\n                    }\n                    constructor.setAccessible(true);\n                    setLayoutManager(constructor.newInstance(constructorArgs));\n                } catch (ClassNotFoundException e) {\n                    throw new IllegalStateException(attrs.getPositionDescription()\n                            + \": Unable to find LayoutManager \" + className, e);\n                } catch (InvocationTargetException e) {\n                    throw new IllegalStateException(attrs.getPositionDescription()\n                            + \": Could not instantiate the LayoutManager: \" + className, e);\n                } catch (InstantiationException e) {\n                    throw new IllegalStateException(attrs.getPositionDescription()\n                            + \": Could not instantiate the LayoutManager: \" + className, e);\n                } catch (IllegalAccessException e) {\n                    throw new IllegalStateException(attrs.getPositionDescription()\n                            + \": Cannot access non-public constructor \" + className, e);\n                } catch (ClassCastException e) {\n                    throw new IllegalStateException(attrs.getPositionDescription()\n                            + \": Class is not a LayoutManager \" + className, e);\n                }\n            }\n        }\n    }\n","sourceCodeStart":853,"sourceCodeEnd":889,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java#L853-L889","documentation":"During XML inflation of RecyclerView, the app:layoutManager class name is resolved by Class.forName. ClassNotFoundException produces 'Unable to find LayoutManager <className>'. The class string in the attribute could not be loaded at runtime.","triggerScenarios":"app:layoutManager points to a class that does not exist, is misspelled, uses a wrong package, or has been renamed/removed by ProGuard/R8 obfuscation. A relative name (leading '.') is prefixed with the app package — a wrong package base yields a missing class.","commonSituations":"Typo in the class FQN in XML. LayoutManager lives in a library that is not on the classpath at runtime (e.g. dynamic-feature module). Obfuscation renamed the class so the XML string no longer matches. Wrong applicationId makes the '.'-relative resolution resolve to a non-existent package.","solutions":["Verify the fully-qualified class name in app:layoutManager matches a real class on the runtime classpath.","If using '.'-relative names, confirm applicationId matches the package containing the class.","Add a ProGuard -keep rule for any LayoutManager referenced from XML so obfuscation does not rename it."],"exampleFix":"<!-- before -->\n<androidx.recyclerview.widget.RecyclerView\n    app:layoutManager=\"androidx.Recyclerview.widget.GridLayoutManager\"/>\n\n<!-- after -->\n<androidx.recyclerview.widget.RecyclerView\n    app:layoutManager=\"androidx.recyclerview.widget.GridLayoutManager\"/>","handlingStrategy":"validation","validationCode":"static Class<?> resolveLayoutManagerClass(Context ctx, String name) throws ClassNotFoundException {\n    String fqn = name.charAt(0) == '.' ? ctx.getPackageName() + name : name;\n    return Class.forName(fqn, false, ctx.getClassLoader());\n}","typeGuard":"null","tryCatchPattern":"try {\n    Class<?> c = Class.forName(fqn);\n    if (!RecyclerView.LayoutManager.class.isAssignableFrom(c)) throw new IllegalStateException();\n} catch (ClassNotFoundException e) {\n    // log and fall back to a programmatic LayoutManager\n    recyclerView.setLayoutManager(new LinearLayoutManager(ctx));\n}","preventionTips":["Pin layoutManager class names against real classes via an inflation test.","Add ProGuard -keep rules for any LayoutManager referenced from XML.","Prefer programmatic setLayoutManager when the class is obfuscated."],"tags":["recyclerview","layoutmanager","xml-inflation","reflection","proguard"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}