1.安装插件
2.工程build加入
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.5.0' classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' // 添加这行 // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } }
3.app build加入
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt' //添加这行
4.app build加入
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' apt 'com.jakewharton:butterknife-compiler:8.4.0' compile 'com.jakewharton:butterknife:8.4.0' }
5.最后直接鼠标定位到
setContentView(R.layout.xxx)中点击右键generate,然后下面有个generate butternife