配置请参考这个:https://www.jianshu.com/p/c61172bfa49b
过程中如果出现:
Error:android-apt plugin is incompatible with the Android Gradle plugin.
Please use 'annotationProcessor' configuration instead.
- 注释掉 apply plugin: ‘android-apt’
apply plugin: 'com.android.application'
//apply plugin: 'android-apt'
- 把dependencies下的 apt 全部改为 annotationProcessor
// apt 'com.jakewharton:butterknife-compiler:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
至于原理可以看这个:https://www.jianshu.com/p/39fc66aa3297