{"record":{"id":"67d70b1cf4961ca9","repo":"JakeWharton/butterknife","slug":"bindbool-field-type-must-be-boolean","errorCode":null,"errorMessage":"@BindBool field type must be 'boolean'. (","messagePattern":"@BindBool field type must be 'boolean'\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":446,"sourceCode":"    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();\n    Resources resources = source.getContext().getResources();\n\n    Object value;\n    Class<?> fieldType = field.getType();\n    if (fieldType == boolean.class) {\n      value = resources.getBoolean(id);\n    } else {\n      throw new IllegalStateException(\"@BindBool field type must be 'boolean'. (\"\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 parseBindColor(Object target, Field field, View source) {\n    BindColor bindColor = field.getAnnotation(BindColor.class);\n    if (bindColor == null) {\n      return null;\n    }\n    validateMember(field);\n\n    int id = bindColor.value();","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L428-L464","documentation":"@BindBool reads a boolean resource with Resources.getBoolean, so parseBindBool requires the field's type to be the primitive boolean. A Boolean (boxed), int, or any other type throws this IllegalStateException at bind time. The compiler flavor enforces the identical rule during annotation processing.","triggerScenarios":"`@BindBool(R.bool.is_tablet) Boolean isTablet;` (boxed wrapper instead of primitive); Kotlin properties whose backing field resolves to Boolean; annotating an int flag field with @BindBool.","commonSituations":"Kotlin `var isTablet: Boolean = false` with the annotation landing on a boxed context; Java developers using the wrapper type out of habit; nullable boolean fields.","solutions":["Change the field to primitive boolean: `@BindBool(R.bool.is_tablet) boolean isTablet;`","In Kotlin, use a non-null `Boolean` property so the backing field is primitive"],"exampleFix":"// before\n@BindBool(R.bool.is_tablet)\nBoolean isTablet; // boxed\n\n// after\n@BindBool(R.bool.is_tablet)\nboolean isTablet;","handlingStrategy":"type-guard","validationCode":"if (field.getType() != boolean.class) {\n  throw new IllegalStateException(\"@BindBool field must be primitive boolean: \" + field);\n}","typeGuard":"static boolean isPrimitiveBooleanField(Field f) {\n  return f.getType() == boolean.class;\n}","tryCatchPattern":null,"preventionTips":["Use primitive boolean (not Boolean) for @BindBool fields","In Kotlin, declare non-null Boolean properties so the backing field stays primitive"],"tags":["butterknife","runtime","reflection","type-mismatch","boxing"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}