{"record":{"id":"8acc5506993927dd","repo":"JakeWharton/butterknife","slug":"bindview-fields-must-extend-from-view-or-be-an-in","errorCode":null,"errorMessage":"@BindView fields must extend from View or be an interface. (","messagePattern":"@BindView fields 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":250,"sourceCode":"      if (debug) Log.d(TAG, \"MISS: Reached framework class. Abandoning search.\");\n      return Unbinder.EMPTY;\n    }\n\n    if (debug) Log.d(TAG, \"HIT: Reflectively found \" + unbinders.size() + \" bindings.\");\n    return new CompositeUnbinder(unbinders);\n  }\n\n  private static @Nullable Unbinder parseBindView(Object target, Field field, View source) {\n    BindView bindView = field.getAnnotation(BindView.class);\n    if (bindView == null) {\n      return null;\n    }\n    validateMember(field);\n\n    int id = bindView.value();\n    Class<?> viewClass = field.getType();\n    if (!View.class.isAssignableFrom(viewClass) && !viewClass.isInterface()) {\n      throw new IllegalStateException(\n          \"@BindView fields must extend from View or be an interface. (\"\n              + field.getDeclaringClass().getName()\n              + '.'\n              + field.getName()\n              + ')');\n    }\n\n    String who = \"field '\" + field.getName() + \"'\";\n    Object view = Utils.findOptionalViewAsType(source, id, who, viewClass);\n    trySet(field, target, view);\n\n    return new FieldUnbinder(target, field);\n  }\n\n  private static @Nullable Unbinder parseBindViews(Object target, Field field, View source) {\n    BindViews bindViews = field.getAnnotation(BindViews.class);\n    if (bindViews == null) {\n      return null;","sourceCodeStart":232,"sourceCodeEnd":268,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L232-L268","documentation":"parseBindView requires the annotated field's type to be a subclass of android.view.View or an interface (so the found view can be cast). Any other type — a String, a Drawable, a primitive, or a non-View class — throws this IllegalStateException during ButterKnife.bind in the reflect flavor. The compiler flavor enforces the same rule at build time; the reflect flavor enforces it at runtime.","triggerScenarios":"Annotating a field of a non-View type with @BindView, e.g. `@BindView(R.id.name) String name;` or `@BindView(R.id.icon) Drawable icon;`; using a custom class that wraps a view instead of extending View.","commonSituations":"Migrating from findViewById-style code where an id mapped to a resource rather than a view; intending @BindString/@BindDrawable but typing @BindView; generics or Parcelable fields annotated by mistake.","solutions":["Change the field type to a View subclass matching the XML tag (TextView, ImageView, custom View)","If the ID refers to a resource rather than a view, use the matching annotation: @BindString, @BindDrawable, @BindColor, @BindDimen","For collections of views use @BindViews with a List or array of a View type"],"exampleFix":"// before\n@BindView(R.id.user_name)\nString userName;\n\n// after\n@BindView(R.id.user_name)\nTextView userNameView;","handlingStrategy":"type-guard","validationCode":"Class<?> t = field.getType();\nif (!View.class.isAssignableFrom(t) && !t.isInterface()) {\n  throw new IllegalStateException(\"@BindView on non-View field: \" + field);\n}","typeGuard":"static boolean isBindableViewType(Class<?> c) {\n  return View.class.isAssignableFrom(c) || c.isInterface();\n}","tryCatchPattern":null,"preventionTips":["Use @BindView only for View subclasses or interfaces (e.g. CheckableView)","Use @BindString/@BindDrawable/@BindColor for non-view resources","Prefer the annotation processor over butterknife-reflect so type errors surface at compile time"],"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"}