{"record":{"id":"228bf24110d64cb3","repo":"JakeWharton/butterknife","slug":"bindviews-must-be-a-list-or-array","errorCode":null,"errorMessage":"@BindViews must be a List or array. (","messagePattern":"@BindViews must be a List or array\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":291,"sourceCode":"    Class<?> viewClass;\n    boolean isArray = fieldClass.isArray();\n    if (isArray) {\n      viewClass = fieldClass.getComponentType();\n    } else if (fieldClass == List.class) {\n      Type fieldType = field.getGenericType();\n      if (fieldType instanceof ParameterizedType) {\n        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()","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L273-L309","documentation":"@BindViews only supports two field shapes: an array or exactly java.util.List. parseBindViews checks field.getType(); anything else — an ArrayList subtype, a Collection, a Set, a single View, a CharSequence — falls into the final else and throws this IllegalStateException at bind time.","triggerScenarios":"`@BindViews({...}) ArrayList<TextView> views;` (ArrayList is a subtype, not List itself); `Set<TextView>`; `Collection<TextView>`; annotating a single View field with @BindViews.","commonSituations":"Developers declaring concrete collection implementations (ArrayList/LinkedList) instead of the List interface; mixing up @BindView (single) and @BindViews (many).","solutions":["Declare the field as `List<TextView>` (or `TextView[]`) instead of ArrayList/Set/Collection","Use @BindView on a single-view field instead of @BindViews"],"exampleFix":"// before\n@BindViews({R.id.a, R.id.b})\nArrayList<TextView> labels;\n\n// after\n@BindViews({R.id.a, R.id.b})\nList<TextView> labels;","handlingStrategy":"type-guard","validationCode":"Class<?> t = field.getType();\nif (!t.isArray() && t != List.class) {\n  throw new IllegalStateException(\"@BindViews needs List or array: \" + field);\n}","typeGuard":"static boolean isBindViewsContainer(Field f) {\n  Class<?> t = f.getType();\n  return t.isArray() || t == List.class;\n}","tryCatchPattern":null,"preventionTips":["Declare @BindViews fields as the List interface or an array, never ArrayList/Set/Collection","Use @BindView for a single view"],"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"}