Easy to use:

Steps:
1, File -> Settings -> Plugins -> Install Android ButterKnife Plugin Plus
2, add classpath to dependecies in build.gradle (project level)

buildscript {
repositories {
jcenter()
}
dependencies {
classpath ‘com.android.tools.build:gradle:2.3.0’
classpath ‘com.jakewharton:butterknife-gradle-plugin:8.5.1’
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

3, add plugins to build.gradle (app level)
apply plugin: ‘com.android.library’
apply plugin: ‘com.jakewharton.butterknife’

and

dependencies {
compile ‘com.jakewharton:butterknife:8.5.1’
annotationProcessor ‘com.jakewharton:butterknife-compiler:8.5.1’
}

and You are done. You can use it now.

Examples:

activity onCreate method adds this:
ButterKnife.bind(this);

and you can use binding on the class level like this:
@BindView(R2.id.imageView) ImageView imageView;

Make sure you are using R2 for Id!

Link for the project!

Enjoy !

Advertisements