ButterKnife 8.0.1 not working

前端 未结 10 1156
粉色の甜心
粉色の甜心 2020-12-05 16:42

I am using butterknife 8.0.1, but a nullpointerexception is appearing.

This line is on my build.grade file: compile \'com.ja

相关标签:
10条回答
  • 2020-12-05 17:40

    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
    
    0 讨论(0)
  • 2020-12-05 17:41

    Add annotationProcessor 'com.jakewharton:butterknife-compiler:8.6.0' In your gradle file it worked for me

    0 讨论(0)
  • 2020-12-05 17:42

    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.

    0 讨论(0)
  • 2020-12-05 17:42

    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.

    0 讨论(0)
提交回复
热议问题