Android Studio: Integration von Butterknife?

Ich versuche zu implementierenButtermesse in mein Android Studio-Projekt.

How, wenn ich das tue, erhalte ich eine Fehlermeldung auf@InjectView "Symbol InjectView kann nicht aufgelöst werden".

Habe ich Butterknife nicht erfolgreich implementiert?

Aktivitätscode:

package com.example.rodf.testapp;

import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;


public class MainActivity extends ActionBarActivity {

    @InjectView(R.id.tvHelloWorld) TextView tv1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



    }
}

Layout

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">

    <TextView
        android:id="@+id/tvHelloWorld"
        android:text="@string/hello_world" android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



</RelativeLayout>

gradle Datei:

apply plugin: 'com.android.application'

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'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:21.0.3'
    //adding the butter knife library
    compile 'com.jakewharton:butterknife:6.0.0'
}

Antworten auf die Frage(14)

Ihre Antwort auf die Frage