{"record":{"id":"f92b92946d4d368e","repo":"JakeWharton/butterknife","slug":"bindbitmap-field-type-must-be-bitmap","errorCode":null,"errorMessage":"@BindBitmap field type must be 'Bitmap'. (","messagePattern":"@BindBitmap field type must be 'Bitmap'\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":420,"sourceCode":"    return Unbinder.EMPTY;\n  }\n\n  private static @Nullable Unbinder parseBindBitmap(Object target, Field field, View source) {\n    BindBitmap bindBitmap = field.getAnnotation(BindBitmap.class);\n    if (bindBitmap == null) {\n      return null;\n    }\n    validateMember(field);\n\n    int id = bindBitmap.value();\n    Resources resources = source.getContext().getResources();\n\n    Object value;\n    Class<?> fieldType = field.getType();\n    if (fieldType == Bitmap.class) {\n      value = BitmapFactory.decodeResource(resources, id);\n    } else {\n      throw new IllegalStateException(\"@BindBitmap field type must be 'Bitmap'. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n    trySet(field, target, value);\n\n    return Unbinder.EMPTY;\n  }\n\n  private static @Nullable Unbinder parseBindBool(Object target, Field field, View source) {\n    BindBool bindBool = field.getAnnotation(BindBool.class);\n    if (bindBool == null) {\n      return null;\n    }\n    validateMember(field);\n\n    int id = bindBool.value();","sourceCodeStart":402,"sourceCodeEnd":438,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L402-L438","documentation":"@BindBitmap decodes a resource into an android.graphics.Bitmap via BitmapFactory.decodeResource, so parseBindBitmap requires the field type to be exactly Bitmap. Any other type — Drawable, ImageView, Bitmaap subclasses like BitmapDrawable — throws this IllegalStateException at bind time.","triggerScenarios":"`@BindBitmap(R.drawable.logo) Drawable logo;` or `@BindBitmap(...) ImageView logo;` — field types that are not Bitmap.","commonSituations":"Confusing bitmap resources with drawable resources; intending @BindDrawable for a Drawable field; annotating the ImageView that displays the image instead of a Bitmap field.","solutions":["Declare the field as `Bitmap`: `@BindBitmap(R.drawable.logo) Bitmap logo;`","If you need a Drawable, use @BindDrawable instead","If you need the ImageView, use @BindView and load the bitmap into it separately"],"exampleFix":"// before\n@BindBitmap(R.drawable.logo)\nDrawable logo;\n\n// after\n@BindBitmap(R.drawable.logo)\nBitmap logo;","handlingStrategy":"type-guard","validationCode":"if (field.getType() != Bitmap.class) {\n  throw new IllegalStateException(\"@BindBitmap field must be Bitmap: \" + field);\n}","typeGuard":"static boolean isBitmapField(Field f) {\n  return f.getType() == android.graphics.Bitmap.class;\n}","tryCatchPattern":null,"preventionTips":["Type @BindBitmap fields exactly as Bitmap; use @BindDrawable for Drawables","Bind the ImageView with @BindView and set the bitmap separately"],"tags":["butterknife","runtime","reflection","type-mismatch","bitmap"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}