JakeWharton/butterknife · error · Resources.NotFoundException

Resource ID #0x{} type #0x{} is not valid

Error message

Resource ID #0x{} type #0x{} is not valid

What it means

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.

Source

Thrown at butterknife-runtime/src/main/java/butterknife/internal/Utils.java:48

          + tintAttrId
          + " was not found.");
    }

    Drawable drawable = ContextCompat.getDrawable(context, id);
    drawable = DrawableCompat.wrap(drawable.mutate());
    int color = ContextCompat.getColor(context, VALUE.resourceId);
    DrawableCompat.setTint(drawable, color);
    return drawable;
  }

  @UiThread // Implicit synchronization for use of shared resource VALUE.
  public static float getFloat(Context context, @DimenRes int id) {
    TypedValue value = VALUE;
    context.getResources().getValue(id, value, true);
    if (value.type == TypedValue.TYPE_FLOAT) {
      return value.getFloat();
    }
    throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id)
        + " type #0x" + Integer.toHexString(value.type) + " is not valid");
  }

  @SafeVarargs
  public static <T> T[] arrayFilteringNull(T... views) {
    int end = 0;
    int length = views.length;
    for (int i = 0; i < length; i++) {
      T view = views[i];
      if (view != null) {
        views[end++] = view;
      }
    }
    return end == length
        ? views
        : Arrays.copyOf(views, end);
  }

View on GitHub (pinned to fcdebedf32)

Solutions

  1. Redeclare the resource with float format: `<item name="ratio" format="float" type="dimen">0.75</item>`.
  2. If the value is an integer, use @BindInt; if a real dimension with units, use @BindDimen.
  3. After editing resources, rebuild so R references match the new entries.

Example fix

<!-- before -->
<dimen name="completion_ratio">75</dimen>

<!-- after -->
<item name="completion_ratio" format="float" type="dimen">0.75</item>
Defensive patterns

Strategy: validation

Validate before calling

TypedValue tv = new TypedValue();
getResources().getValue(R.dimen.ratio, tv, true);
if (tv.type != TypedValue.TYPE_FLOAT) {
  throw new IllegalStateException("R.dimen.ratio is not float-format");
}

Prevention

When it happens

Trigger: `@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>`.

Common situations: 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.

Related errors


AI-assisted analysis of JakeWharton/butterknife@fcdebedf32 (2026-08-14). Data as JSON: /api/errors/a1653e21e521b421. Report an issue: GitHub.