explaingit

jakewharton/butterknife

25,376JavaAudience · developerComplexity · 2/5DormantLicenseSetup · easy

TLDR

Android library that eliminated boilerplate code for connecting UI elements to Java code using simple annotations instead of repetitive findViewById calls.

Mindmap

mindmap
  root((repo))
    What it does
      Eliminates findViewById boilerplate
      Wires UI to Java code
      Uses annotations
    How it works
      BindView annotation
      OnClick annotation
      Compile-time code generation
    Use cases
      Faster Android UI development
      Cleaner controller code
      Reduce repetitive lookups
    Status
      Now deprecated
      Replaced by view binding
      Legacy projects still use

Things people build with this

USE CASE 1

Speed up Android app development by eliminating repetitive findViewById code for connecting buttons and text fields.

USE CASE 2

Write cleaner Android controller code by using @BindView and @OnClick annotations instead of manual UI wiring.

USE CASE 3

Maintain legacy Android projects that were built with Butter Knife before view binding became available.

Tech stack

JavaAndroidAnnotation Processing

Getting it running

Difficulty · easy Time to first run · 5min
Use freely for any purpose, including commercial use, as long as you keep the copyright notice and license text.

In plain English

Butter Knife was an Android library that reduced repetitive boilerplate code when connecting a user interface layout (the visual elements of an Android screen) to the Java code that controls them. In Android development, developers traditionally had to write many lines of "findViewById" calls, code that searches through the UI layout to locate each button, text box, or image by its ID, then assigns it to a variable. Butter Knife replaced all of that with simple annotations (labels you add directly above a variable or method). For example, instead of writing multi-line lookup code for a text field, you would place "@BindView" above a variable and Butter Knife would wire everything up automatically at compile time, generating the repetitive code for you behind the scenes using a technique called annotation processing. Similarly, instead of creating anonymous listener objects to respond to button clicks, you could annotate a method with "@OnClick" and that method would be called automatically when the button was tapped. Note: Butter Knife is now officially deprecated. Google has since built a native replacement called view binding directly into Android, which accomplishes the same goal more safely and without a third-party library. Existing code using Butter Knife will continue to work, but new projects should use view binding instead. The tech stack is Java.

Copy-paste prompts

Prompt 1
Show me how to use @BindView and @OnClick annotations in Butter Knife to wire up an Android activity's UI elements.
Prompt 2
How does Butter Knife's annotation processing work at compile time to generate the findViewById code automatically?
Prompt 3
I have an old Android project using Butter Knife. What's the migration path to Google's view binding?
Prompt 4
Create an example Android activity using Butter Knife annotations to bind a button and text field instead of findViewById calls.
Open on GitHub → Explain another repo

Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.