{"record":{"id":"3b1b63f38f36108a","repo":"airbnb/epoxy","slug":"could-not-find-model-for-view-type","errorCode":null,"errorMessage":"Could not find model for view type: ","messagePattern":"Could not find model for view type: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"epoxy-adapter/src/main/java/com/airbnb/epoxy/ViewTypeManager.java","lineNumber":92,"sourceCode":"    }\n\n    adapter.onExceptionSwallowed(\n        new IllegalStateException(\"Last model did not match expected view type\"));\n\n    // To be extra safe in case RecyclerView implementation details change...\n    for (EpoxyModel<?> model : adapter.getCurrentModels()) {\n      if (getViewType(model) == viewType) {\n        return model;\n      }\n    }\n\n    // Check for the hidden model.\n    HiddenEpoxyModel hiddenEpoxyModel = new HiddenEpoxyModel();\n    if (viewType == hiddenEpoxyModel.getViewType()) {\n      return hiddenEpoxyModel;\n    }\n\n    throw new IllegalStateException(\"Could not find model for view type: \" + viewType);\n  }\n}\n","sourceCodeStart":74,"sourceCodeEnd":95,"githubUrl":"https://github.com/airbnb/epoxy/blob/e45bd3a61fe3a1f130e184f5b8dcf172ab99025a/epoxy-adapter/src/main/java/com/airbnb/epoxy/ViewTypeManager.java#L74-L95","documentation":"When the RecyclerView needs to create a view for a given view type, Epoxy looks up the model registered with that type. If no model matches the viewType (and it is not the hidden model's type), this IllegalStateException is thrown, indicating the adapter's view-type registry is out of sync with the models.","triggerScenarios":"onCreateViewHolder receiving a viewType that no longer maps to any model — e.g., adapter models changed while a stale viewType is requested, or a custom getModelForViewType/viewType assignment collision.","commonSituations":"Updating the Epoxy library or changing model classes so generated view types shift while old layout state is restored; restoring RecyclerView state after a model list change; duplicate getViewType values from custom models.","solutions":["Clear the RecyclerView's saved state / adapter state so stale view types are not requested","Ensure models use unique view types and that all models bound to the adapter are still registered","Update epoxy-adapter so model and adapter view-type generation are in sync","Rebuild the adapter's model list (epoxyRecyclerView.requestModelBuild or adapter.setModels) before layouts resume"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure adapter models are set before layout: check recyclerView.adapter != null and models list non-empty","typeGuard":null,"tryCatchPattern":"try { recyclerView.adapter = epoxyAdapter } catch (e: IllegalStateException) { epoxyAdapter.requestRebuild(); recyclerView.adapter = epoxyAdapter }","preventionTips":["Clear RecyclerView saved state after major model list changes","Keep model set and adapter updates atomic","Avoid custom getViewType overrides that can collide","Pin epoxy-adapter versions across modules"],"tags":["android","epoxy","recyclerview","viewtype"],"backgroundTag":"record-not-found","analyzedSha":"e45bd3a61fe3a1f130e184f5b8dcf172ab99025a","analyzedAt":"2026-09-13T03:24:16.052Z","contentChangedAt":"2026-09-13T03:24:16.052Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}