{"record":{"id":"37b892304c2d791d","repo":"yuliskov/SmartTube","slug":"wrong-message-view-type-please-report-this-issue","errorCode":null,"errorMessage":"Wrong message view type. Please, report this issue on GitHub with full stacktrace in description.","messagePattern":"Wrong message view type\\. Please, report this issue on GitHub with full stacktrace in description\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"chatkit/src/main/java/com/stfalcon/chatkit/messages/MessageHolders.java","lineNumber":571,"sourceCode":"            case VIEW_TYPE_TEXT_MESSAGE:\n                return getHolder(parent, incomingTextConfig, messagesListStyle);\n            case -VIEW_TYPE_TEXT_MESSAGE:\n                return getHolder(parent, outcomingTextConfig, messagesListStyle);\n            case VIEW_TYPE_IMAGE_MESSAGE:\n                return getHolder(parent, incomingImageConfig, messagesListStyle);\n            case -VIEW_TYPE_IMAGE_MESSAGE:\n                return getHolder(parent, outcomingImageConfig, messagesListStyle);\n            default:\n                for (ContentTypeConfig typeConfig : customContentTypes) {\n                    if (Math.abs(typeConfig.type) == Math.abs(viewType)) {\n                        if (viewType > 0)\n                            return getHolder(parent, typeConfig.incomingConfig, messagesListStyle);\n                        else\n                            return getHolder(parent, typeConfig.outcomingConfig, messagesListStyle);\n                    }\n                }\n        }\n        throw new IllegalStateException(\"Wrong message view type. Please, report this issue on GitHub with full stacktrace in description.\");\n    }\n\n    @SuppressWarnings(\"unchecked\")\n    protected void bind(final ViewHolder holder, final Object item, boolean isSelected,\n                        final ImageLoader imageLoader,\n                        final View.OnClickListener onMessageClickListener,\n                        final View.OnLongClickListener onMessageLongClickListener,\n                        final View.OnFocusChangeListener onMessageFocusChangeListener,\n                        final DateFormatter.Formatter dateHeadersFormatter,\n                        final SparseArray<MessagesListAdapter.OnMessageViewClickListener> clickListenersArray) {\n\n        if (item instanceof IMessage) {\n            ((MessageHolders.BaseMessageViewHolder) holder).isSelected = isSelected;\n            ((MessageHolders.BaseMessageViewHolder) holder).imageLoader = imageLoader;\n            holder.itemView.setOnLongClickListener(onMessageLongClickListener);\n            holder.itemView.setOnClickListener(onMessageClickListener);\n            holder.itemView.setOnFocusChangeListener(onMessageFocusChangeListener);\n","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/chatkit/src/main/java/com/stfalcon/chatkit/messages/MessageHolders.java#L553-L589","documentation":"getViewHolder maps the int viewType RecyclerView hands it to a holder config: built-ins are handled by the switch, custom types by scanning customContentTypes with Math.abs matching (sign still encodes direction). The IllegalStateException fires only when the viewType matches nothing — the library itself labels this a should-never-happen branch and asks for a GitHub report. In practice it means the holders instance creating holders disagrees with the view types actually in flight.","triggerScenarios":"RecyclerView requesting a viewType produced by a different MessageHolders configuration, e.g. an adapter constructed with holders that never registered the custom type now being bound; swapping adapters with different holder configs on a MessagesList whose recycled views carry stale view types; a ContentChecker returning true for a type that was not registered on this MessageHolders instance.","commonSituations":"Creating a new MessagesListAdapter with default holders while reusing the same MessagesList for custom content-type messages; a shared adapter across screens with per-screen holder configs; version upgrades where view-type numbering changed.","solutions":["Build every MessagesListAdapter with the exact MessageHolders instance on which the custom types were registered, and never swap to an adapter with different types on the same list","When you must change adapter shape on an existing MessagesList, use a fresh list or clear the RecycledViewPool first","If neither applies, capture the full stacktrace and report it on the stfalcon chatkit GitHub tracker as the message requests"],"exampleFix":"// before\nlist.setAdapter(new MessagesListAdapter<>(senderId, new MessageHolders())); // custom types were registered on a different holders instance\n\n// after\nMessageHolders holders = new MessageHolders().registerContentType((byte) 1, ...);\nlist.setAdapter(new MessagesListAdapter<>(senderId, holders));","handlingStrategy":"validation","validationCode":"// Before swapping adapters with different holder shapes on the same list:\nmessagesList.getRecycledViewPool().clear();\nmessagesList.setAdapter(new MessagesListAdapter<>(senderId, sameHoldersInstance));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Construct every MessagesListAdapter with the same MessageHolders instance that registered your content types","Do not reuse one MessagesList for adapters with different custom types without clearing the recycled view pool","Make ContentChecker return true only for types actually registered on that holders instance"],"tags":["chatkit","viewholder","view-type","recyclerview","recycling"],"backgroundTag":"unregistered-view-type","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}