Search code examples
androidbutterknife

ButterKnife first use error


after my suffering from findViewById I decided to use ButterKnife but nice bug told me that you will never ues ButterKnife here is the error

@InjectView-annotated class incorrectly in Android framework package.

why? where is my mistake? is gradle dependency wrong?

I saw this post but it didn't help me

gradle file (module)

apply plugin: 'com.neenbedankt.android-apt'
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    }
}

dependencies {
    compile 'com.jakewharton:butterknife:8.0.1'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
}

the error in this line

@BindView(R.id.button_birth_date)
private Button buttonBirthDate;

and other member variables(views) that uses @BindView


Solution

  • By Jake Wharton, The exception says it all:

    @InjectView-annotated class incorrectly in Android framework package. 
    

    Your class is in the Android framework package, android.. Applications should not use the android. or java.* packages for their code. ButterKnife will eagerly reject these packages.

    Change your package name. android.alcode.com.material to something.alcode.com.material