I am using butterknife 8.0.1
, but a nullpointerexception
is appearing.
This line is on my build.grade file:
compile \'com.ja
for me the problem was that I was using
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
instead of
apt 'com.jakewharton:butterknife-compiler:8.7.0
Add annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0'
In your gradle file it worked for me
Per the readme, you need to include the butterknife-compiler
in order for the generated code to be produced automatically:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
apply plugin: 'com.neenbedankt.android-apt'
dependencies {
compile 'com.jakewharton:butterknife:8.0.1'
apt 'com.jakewharton:butterknife-compiler:8.0.1'
}
Without this there is no generated code to be loaded and thus none of the fields get set.
You can verify ButterKnife is working by calling ButterKnife.setDebug(true)
and looking in Logcat.
I have just faced this problem, after updating my project to Gradle version 3.0.1
. I was able to fix it by just including in Gradle app
file the line:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
The final result was:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
...
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
I hope this helps somebody, although this question being old.