{"record":{"id":"c9f8a05f0f61db73","repo":"DrKLO/Telegram","slug":"positiondescription-class-is-not-a-layoutmanage","errorCode":null,"errorMessage":"{positionDescription}: Class is not a LayoutManager {className}","messagePattern":"(.+?): Class is not a LayoutManager (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java","lineNumber":883,"sourceCode":"                                    + \": 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\n    private String getFullClassName(Context context, String className) {\n        if (className.charAt(0) == '.') {\n            return context.getPackageName() + className;\n        }\n        if (className.contains(\".\")) {\n            return className;\n        }\n        return RecyclerView.class.getPackage().getName() + '.' + className;\n    }\n\n    private void initChildrenHelper() {\n        mChildHelper = new ChildHelper(new ChildHelper.Callback() {","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/DrKLO/Telegram/blob/45ab8f4308496e1f01026a97fcdb0d58a5274474/TMessagesProj/src/main/java/androidx/recyclerview/widget/RecyclerView.java#L865-L901","documentation":"The class named by app:layoutManager loads and instantiates, but is not a subclass of RecyclerView.LayoutManager (the earlier asSubclass(LayoutManager.class) succeeded via the typed path, yet a ClassCastException surfaces during newInstance/setLayoutManager). RecyclerView reports 'Class is not a LayoutManager'.","triggerScenarios":"app:layoutManager names a class that is NOT a LayoutManager subclass (e.g. a ViewHolder, an Adapter, a plain View). The asSubclass check passed via a different code shape but the assignment to setLayoutManager fails the cast.","commonSituations":"Confusing the layoutManager attribute with the view class itself. Pasting a class name from a different framework role (Adapter vs LayoutManager).","solutions":["Ensure app:layoutManager names a concrete subclass of RecyclerView.LayoutManager (LinearLayoutManager, GridLayoutManager, StaggeredGridLayoutManager, or your own subclass).","Double-check the FQN against the actual class hierarchy.","If you only need a different view type, that belongs on the item layout / Adapter, not layoutManager."],"exampleFix":"<!-- before -->\n<androidx.recyclerview.widget.RecyclerView\n    app:layoutManager=\"com.example.MyRecyclerAdapter\"/>\n\n<!-- after -->\n<androidx.recyclerview.widget.RecyclerView\n    app:layoutManager=\"androidx.recyclerview.widget.LinearLayoutManager\"/>","handlingStrategy":"type-guard","validationCode":"static void assertLayoutManager(Class<?> c) {\n    if (!RecyclerView.LayoutManager.class.isAssignableFrom(c)) {\n        throw new IllegalArgumentException(c.getName() + \" is not a LayoutManager\");\n    }\n}","typeGuard":"static boolean isLayoutManagerClass(Class<?> c) {\n    return RecyclerView.LayoutManager.class.isAssignableFrom(c);\n}","tryCatchPattern":"null","preventionTips":["Cross-check the layoutManager class FQN against a LayoutManager subclass.","Do not confuse Adapter/ViewHolder class names with LayoutManager.","Add a lint/test that asserts every app:layoutManager resolves to a LayoutManager subclass."],"tags":["recyclerview","layoutmanager","xml-inflation","type-safety"],"backgroundTag":null,"analyzedSha":"45ab8f4308496e1f01026a97fcdb0d58a5274474","analyzedAt":"2026-08-14T05:19:30.815Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}