{"record":{"id":"207174401a51bb0a","repo":"JakeWharton/butterknife","slug":"bindviews-list-or-array-type-must-extend-from-vie","errorCode":null,"errorMessage":"@BindViews List or array type must extend from View or be an interface. (","messagePattern":"@BindViews List or array type must extend from View or be an interface\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":298,"sourceCode":"        Type viewType = ((ParameterizedType) fieldType).getActualTypeArguments()[0];\n        // TODO real rawType impl!!!!\n        viewClass = (Class<?>) viewType;\n      } else {\n        throw new IllegalStateException(\"@BindViews List must have a generic component. (\"\n            + field.getDeclaringClass().getName()\n            + '.'\n            + field.getName()\n            + ')');\n      }\n    } else {\n      throw new IllegalStateException(\"@BindViews must be a List or array. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n    if (!View.class.isAssignableFrom(viewClass) && !viewClass.isInterface()) {\n      throw new IllegalStateException(\n          \"@BindViews List or array type must extend from View or be an interface. (\"\n              + field.getDeclaringClass().getName()\n              + '.'\n              + field.getName()\n              + ')');\n    }\n\n    int[] ids = bindViews.value();\n    if (ids.length == 0) {\n      throw new IllegalStateException(\"@BindViews must specify at least one ID. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n\n    List<Object> views = new ArrayList<>(ids.length);\n    String who = \"field '\" + field.getName() + \"'\";","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L280-L316","documentation":"After resolving the component type of a @BindViews List or array, the reflect binder requires that component to be a View subclass or an interface (the compiler enforces the same rule). If the element type is something like String, Integer, or a non-View POJO, bind throws this IllegalStateException.","triggerScenarios":"`@BindViews({R.id.a}) List<String> names;` or `@BindViews({...}) String[] names;` — component types that are not Views.","commonSituations":"Trying to batch-bind string/resource values with a view annotation; refactoring a List<TextView> into a list of model objects while leaving @BindViews on it.","solutions":["Change the component type to a View subclass, e.g. List<TextView>","For non-view resources use the single-value annotations (@BindString, @BindDrawable) on separate fields"],"exampleFix":"// before\n@BindViews({R.id.first, R.id.second})\nList<String> labels;\n\n// after\n@BindViews({R.id.first, R.id.second})\nList<TextView> labels;","handlingStrategy":"type-guard","validationCode":"Class<?> component = /* resolved component type */;\nif (!View.class.isAssignableFrom(component) && !component.isInterface()) {\n  throw new IllegalStateException(\"@BindViews component not a View: \" + component);\n}","typeGuard":"static boolean isBindableComponent(Class<?> c) {\n  return View.class.isAssignableFrom(c) || c.isInterface();\n}","tryCatchPattern":null,"preventionTips":["Make List/array component types concrete View subclasses (TextView, ImageView)","Do not bind lists of models or strings with @BindViews"],"tags":["butterknife","runtime","reflection","type-mismatch"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}