{"record":{"id":"854836f9d8761a49","repo":"JakeWharton/butterknife","slug":"bindarray-field-type-must-be-one-of-string-in","errorCode":null,"errorMessage":"@BindArray field type must be one of: String[], int[], CharSequence[], android.content.res.TypedArray. (","messagePattern":"@BindArray field type must be one of: String\\[\\], int\\[\\], CharSequence\\[\\], android\\.content\\.res\\.TypedArray\\. \\(","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"butterknife-reflect/src/main/java/butterknife/ButterKnife.java","lineNumber":385,"sourceCode":"    validateMember(field);\n\n    int id = bindArray.value();\n    Resources resources = source.getContext().getResources();\n\n    Object value;\n    Class<?> fieldType = field.getType();\n    if (fieldType == TypedArray.class) {\n      value = resources.obtainTypedArray(id);\n    } else if (fieldType.isArray()) {\n      Class<?> componentType = fieldType.getComponentType();\n      if (componentType == String.class) {\n        value = resources.getStringArray(id);\n      } else if (componentType == int.class) {\n        value = resources.getIntArray(id);\n      } else if (componentType == CharSequence.class) {\n        value = resources.getTextArray(id);\n      } else {\n        throw new IllegalStateException(\"@BindArray field type must be one of: \"\n            + \"String[], int[], CharSequence[], android.content.res.TypedArray. (\"\n            + field.getDeclaringClass().getName()\n            + '.'\n            + field.getName()\n            + ')');\n      }\n    } else {\n      throw new IllegalStateException(\"@BindArray field type must be one of: \"\n          + \"String[], int[], CharSequence[], android.content.res.TypedArray. (\"\n          + field.getDeclaringClass().getName()\n          + '.'\n          + field.getName()\n          + ')');\n    }\n    trySet(field, target, value);\n\n    return Unbinder.EMPTY;\n  }","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-reflect/src/main/java/butterknife/ButterKnife.java#L367-L403","documentation":"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.","triggerScenarios":"`@BindArray(R.array.ids) long[] ids;`, `@BindArray(...) Integer[] values;` (boxed Integer is not supported), or any other unsupported array component.","commonSituations":"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.","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"],"exampleFix":"// before\n@BindArray(R.array.page_offsets)\nInteger[] offsets;\n\n// after\n@BindArray(R.array.page_offsets)\nint[] offsets;","handlingStrategy":"type-guard","validationCode":"Class<?> c = field.getType().getComponentType();\nif (c != String.class && c != int.class && c != CharSequence.class) {\n  throw new IllegalStateException(\"Unsupported @BindArray component: \" + c);\n}","typeGuard":"static boolean isSupportedArrayComponent(Class<?> c) {\n  return c == String.class || c == int.class || c == CharSequence.class;\n}","tryCatchPattern":null,"preventionTips":["Use primitive int[] rather than Integer[] for integer arrays","Keep @BindArray fields to String[], int[], CharSequence[], or TypedArray"],"tags":["butterknife","runtime","reflection","type-mismatch","resources"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}