Android Studio: Integrating Butterknife?

I am trying to implement Butterknife into my android studio project.

However when I do so I get an error on @InjectView “cannot resolve symbol InjectView”.

  • How to use custom font in android xml?
  • Save an arraylist of Strings to shared preferences
  • Android ActionBar MenuItem LowerCase
  • ionic build android failure - Execution failed for task processDebugResources
  • Empty email field of Firebase Auth User using Facebook Login Integration (Firebase 3.0)
  • Android Facebook SDK: Key hash does not match any stored key hashes when uploading google play
  • Have I not implemented Butterknife sucsessfully?

    Activity code:

    package com.example.rodf.testapp;
    import android.os.Bundle;
    import android.view.Menu;
    import android.view.MenuItem;
    public class MainActivity extends ActionBarActivity {
        @InjectView( TextView tv1;
        protected void onCreate(Bundle savedInstanceState) {


    <RelativeLayout xmlns:android=""
        xmlns:tools="" android:layout_width="match_parent"
        android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
            android:text="@string/hello_world" android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    gradle file:

    apply plugin: ''
    android {
        compileSdkVersion 21
        buildToolsVersion "21.1.2"
        defaultConfig {
            applicationId "com.example.rodf.testapp"
            minSdkVersion 15
            targetSdkVersion 21
            versionCode 1
            versionName "1.0"
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), ''
    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        compile ''
        //adding the butter knife library
        compile 'com.jakewharton:butterknife:6.0.0'

  • Set different minSdkVersion for testAndroid than for main app
  • Is it possible to detect Android devices laying side by side
  • Error opening SupportMapFragment for second time
  • ensure visible on android listview?
  • ActionBarDrawerToggle is not setting Drawer Indicator
  • ImageView not refreshing/reflecting changes
  • 7 Solutions collect form web for “Android Studio: Integrating Butterknife?”

    I think your code is good,

    1. Try to sync your gradle by click enter image description here

    2. Try to go Fileinvalidate Caches and restart your Android studio.

    Also, don’t forget put ButterKnife.inject(this); in onCreate()

    Note that in the latest versions of the ButterKnife library, the @InjectView() annotation is no longer used.

    In stead @Bind( and ButterKnife.bind(this); are used.


    Set up manual configuration for ButterKnife from this link

    File -> Other Settings -> Default Settings

    Compiler -> Annotation Processors -> Check Enable annotation processing

    So ButterKnife just got updated with version 8.5.1

    To use that,

    Add below line inside project-level build.gradle:

    classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'

    Add below lines inside app-level build.gradle:

    // Field and method binding for Android views
    compile 'com.jakewharton:butterknife:8.5.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'

    Apply butterknife plugin as below:

    apply plugin: 'com.jakewharton.butterknife'

    A little change in syntax to previous ButterKnife version is that, now you have to use R2 instead of R while using ButterKnfe annotations.

    To be specific:

    Instead of writing

    TextView mTextView;

    We will be writing

    TextView mTextView;

    and then simply build the project.

    Move the TextView tv1 declaration inside your class.
    Also call the ButterKnife.inject(this); method.

    import butterknife.ButterKnife;
    import butterknife.InjectView;
    public class MainActivity extends ActionBarActivity {
        @InjectView( TextView tv1;
        protected void onCreate(Bundle savedInstanceState) {

    In the latest versions of the ButterKnife library(8.5.1), the @InjectView() annotation is not used.

    You can use @BindView(Component) instead of @InjectView(Component) and instead of using Butterknife.inject(this) use ButterKnife.bind(this)

    I tried all the answer’s but nothing is working for me because in the library they changed something. Insteded of @InjectView try @Bind. It will work fine

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.