JakeWharton/butterknife · error · Resources.NotFoundException

Required tint color attribute with name {} and attribute ID

Error message

Required tint color attribute with name {} and attribute ID {} was not found.

What it means

Thrown as Resources.NotFoundException by Utils.getTintedDrawable when the theme cannot resolve the tint attribute (@BindDrawable's tint field) referenced for a drawable binding. Before touching the drawable, ButterKnife resolves tintAttrId against the activity theme; failure means the attribute does not exist in the effective theme (or the ID itself is stale).

Source

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

import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.IdRes;
import androidx.annotation.UiThread;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import java.util.Arrays;
import java.util.List;

@SuppressWarnings("WeakerAccess") // Used by generated code.
public final class Utils {
  private static final TypedValue VALUE = new TypedValue();

  @UiThread // Implicit synchronization for use of shared resource VALUE.
  public static Drawable getTintedDrawable(Context context,
      @DrawableRes int id, @AttrRes int tintAttrId) {
    boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
    if (!attributeFound) {
      throw new Resources.NotFoundException("Required tint color attribute with name "
          + context.getResources().getResourceEntryName(tintAttrId)
          + " and attribute ID "
          + 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) {

View on GitHub (pinned to fcdebedf32)

Solutions

  1. Set the activity theme to one that defines the attribute (e.g. Theme.AppCompat / Material descendant) in AndroidManifest or setContentView caller.
  2. Use an attribute guaranteed present, e.g. android.R.attr.textColor or a project attr declared in your theme's <item>.
  3. Drop the tint parameter and tint manually with DrawableCompat.setTint where theme control is uncertain.

Example fix

// before
@BindDrawable(value = R.drawable.badge, tint = R.attr.colorAccent) Drawable badge;
<!-- theme = @android:style/Theme (no colorAccent) -->

// after
@BindDrawable(value = R.drawable.badge, tint = R.attr.colorAccent) Drawable badge;
<!-- theme = @style/Theme.AppCompat.Light -->
Defensive patterns

Strategy: validation

Validate before calling

TypedValue tv = new TypedValue();
if (!getTheme().resolveAttribute(tintAttr, tv, true)) {
  // fall back to untinted drawable or fail fast with context
  throw new IllegalStateException("Theme lacks tint attr " + tintAttr);
}

Prevention

When it happens

Trigger: Binding a field `@BindDrawable(value = R.drawable.icon, tint = R.attr.colorAccent) Drawable icon;` where R.attr.colorAccent is not defined/resolvable in the current Activity theme — e.g. a legacy theme missing the AppCompat attributes, or an attribute ID from another package not declared in the theme.

Common situations: Using @BindDrawable tint with an old framework theme (Theme without android: attributes, or a non-Material theme missing colorAccent); library modules referencing R.attr from a dependency not applied in the app's theme; resource-ID skew after a build change so tintAttrId points at a nonexistent entry. Because VALUE is a shared static TypedValue, this can also surface across theme swaps in tests.

Related errors


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