第一步:配置依赖 全局的 build.gradle(app)加上如下:
implementation 'com.jakewharton:butterknife:10.2.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
在build.gradle(app)的android{}中加入以下代码:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
注意:minSdkVersion为24
第二步:在需要使用的activtity类onCreate方法里加上:
ButterKnife.bind(