{"record":{"id":"a1653e21e521b421","repo":"JakeWharton/butterknife","slug":"resource-id-0x-type-0x-is-not-valid","errorCode":null,"errorMessage":"Resource ID #0x{} type #0x{} is not valid","messagePattern":"Resource ID #0x(.+?) type #0x(.+?) is not valid","errorType":"exception","errorClass":"Resources.NotFoundException","httpStatus":null,"severity":"error","filePath":"butterknife-runtime/src/main/java/butterknife/internal/Utils.java","lineNumber":48,"sourceCode":"          + tintAttrId\n          + \" was not found.\");\n    }\n\n    Drawable drawable = ContextCompat.getDrawable(context, id);\n    drawable = DrawableCompat.wrap(drawable.mutate());\n    int color = ContextCompat.getColor(context, VALUE.resourceId);\n    DrawableCompat.setTint(drawable, color);\n    return drawable;\n  }\n\n  @UiThread // Implicit synchronization for use of shared resource VALUE.\n  public static float getFloat(Context context, @DimenRes int id) {\n    TypedValue value = VALUE;\n    context.getResources().getValue(id, value, true);\n    if (value.type == TypedValue.TYPE_FLOAT) {\n      return value.getFloat();\n    }\n    throw new Resources.NotFoundException(\"Resource ID #0x\" + Integer.toHexString(id)\n        + \" type #0x\" + Integer.toHexString(value.type) + \" is not valid\");\n  }\n\n  @SafeVarargs\n  public static <T> T[] arrayFilteringNull(T... views) {\n    int end = 0;\n    int length = views.length;\n    for (int i = 0; i < length; i++) {\n      T view = views[i];\n      if (view != null) {\n        views[end++] = view;\n      }\n    }\n    return end == length\n        ? views\n        : Arrays.copyOf(views, end);\n  }\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/JakeWharton/butterknife/blob/fcdebedf3276096db2f51bf6372b849b5a9c75ed/butterknife-runtime/src/main/java/butterknife/internal/Utils.java#L30-L66","documentation":"Thrown as Resources.NotFoundException by Utils.getFloat (used by @BindFloat) when the referenced resource resolves but its TypedValue type is not TYPE_FLOAT. @BindFloat only accepts a `<item name=\"...\" format=\"float\">` / `<item type=\"dimen\" format=\"float\">` entry; integers, dimensions with units, and strings all fail this check.","triggerScenarios":"`@BindFloat(R.dimen.ratio) float ratio;` where R.dimen.ratio is declared as `<dimen name=\"ratio\">16</dimen>` (integer) or `<dimen name=\"ratio\">16dp</dimen>` instead of `<item name=\"ratio\" format=\"float\" type=\"dimen\">0.75</item>`.","commonSituations":"Assuming any dimen or integer resource works with @BindFloat; migrating a value that was previously an int; using `<dimen>` syntax where a float-format `<item>` is required (the common ButterKnife doc example). Also thrown when the ID is valid in one build flavor but the resource was changed type in another.","solutions":["Redeclare the resource with float format: `<item name=\"ratio\" format=\"float\" type=\"dimen\">0.75</item>`.","If the value is an integer, use @BindInt; if a real dimension with units, use @BindDimen.","After editing resources, rebuild so R references match the new entries."],"exampleFix":"<!-- before -->\n<dimen name=\"completion_ratio\">75</dimen>\n\n<!-- after -->\n<item name=\"completion_ratio\" format=\"float\" type=\"dimen\">0.75</item>","handlingStrategy":"validation","validationCode":"TypedValue tv = new TypedValue();\ngetResources().getValue(R.dimen.ratio, tv, true);\nif (tv.type != TypedValue.TYPE_FLOAT) {\n  throw new IllegalStateException(\"R.dimen.ratio is not float-format\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare @BindFloat resources as `<item format=\"float\" type=\"dimen\">0.75</item>`, never <dimen> with units.","Run a quick TypedValue check in CI resource linting if you use many float resources."],"tags":["butterknife","resources","bindfloat","typedvalue","not-found"],"backgroundTag":null,"analyzedSha":"fcdebedf3276096db2f51bf6372b849b5a9c75ed","analyzedAt":"2026-08-14T10:13:55.083Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}