JakeWharton/butterknife · error · IllegalStateException
@BindArray field type must be one of: String[], int[], CharS
Error message
@BindArray field type must be one of: String[], int[], CharSequence[], android.content.res.TypedArray. (
What it means
This branch of parseBindArray throws when the field is an array type but its component type is none of the supported ones (String, int, CharSequence). @BindArray can only populate String[], int[], CharSequence[], or TypedArray; e.g. `long[]` or `Integer[]` hits this IllegalStateException at bind time.
Source
Thrown at butterknife-reflect/src/main/java/butterknife/ButterKnife.java:385
validateMember(field);
int id = bindArray.value();
Resources resources = source.getContext().getResources();
Object value;
Class<?> fieldType = field.getType();
if (fieldType == TypedArray.class) {
value = resources.obtainTypedArray(id);
} else if (fieldType.isArray()) {
Class<?> componentType = fieldType.getComponentType();
if (componentType == String.class) {
value = resources.getStringArray(id);
} else if (componentType == int.class) {
value = resources.getIntArray(id);
} else if (componentType == CharSequence.class) {
value = resources.getTextArray(id);
} else {
throw new IllegalStateException("@BindArray field type must be one of: "
+ "String[], int[], CharSequence[], android.content.res.TypedArray. ("
+ field.getDeclaringClass().getName()
+ '.'
+ field.getName()
+ ')');
}
} else {
throw new IllegalStateException("@BindArray field type must be one of: "
+ "String[], int[], CharSequence[], android.content.res.TypedArray. ("
+ field.getDeclaringClass().getName()
+ '.'
+ field.getName()
+ ')');
}
trySet(field, target, value);
return Unbinder.EMPTY;
}View on GitHub (pinned to fcdebedf32)
Solutions
- Use one of the supported types: String[], int[], CharSequence[], or TypedArray
- For a boxed Integer[] need, switch the field to int[] and box values yourself after bind
Example fix
// before @BindArray(R.array.page_offsets) Integer[] offsets; // after @BindArray(R.array.page_offsets) int[] offsets;
Defensive patterns
Strategy: type-guard
Validate before calling
Class<?> c = field.getType().getComponentType();
if (c != String.class && c != int.class && c != CharSequence.class) {
throw new IllegalStateException("Unsupported @BindArray component: " + c);
} Type guard
static boolean isSupportedArrayComponent(Class<?> c) {
return c == String.class || c == int.class || c == CharSequence.class;
} Prevention
- Use primitive int[] rather than Integer[] for integer arrays
- Keep @BindArray fields to String[], int[], CharSequence[], or TypedArray
When it happens
Trigger: `@BindArray(R.array.ids) long[] ids;`, `@BindArray(...) Integer[] values;` (boxed Integer is not supported), or any other unsupported array component.
Common situations: Resource arrays defined as integers but the field declared boxed; using long arrays for large ID lists; code generation that picks a wrong component type.
Related errors
- @BindView fields must extend from View or be an interface. (
- @BindViews must be a List or array. (
- @BindViews List or array type must extend from View or be an
- @BindAnim field type must be 'Animation'. (
- @BindBitmap field type must be 'Bitmap'. (
AI-assisted analysis of JakeWharton/butterknife@fcdebedf32 (2026-08-14).
Data as JSON: /api/errors/854836f9d8761a49.
Report an issue: GitHub.