ButterKnife 8.0.1 not working

前端 未结 10 1154
粉色の甜心
粉色の甜心 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: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.

提交回复
热议问题