Android 模块化下ButterKnife集成
2018-08-09 本文已影响155人
舒童1024
笑渐不闻声渐悄,多情却被无情恼。
首先说一下我的 AS 3.14,target 27

官网的单模块下集成没问题---》最新版本 8.8.1
多模块化的集成正确姿势
1.在Project的 build.gradle中引入插件 (看清楚 是在Project 中的 gradle)
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
注意 网上有人 8.5.1 可以 我亲自试了下 是不可以的 还是用回8.4.0 花了一天时间 ............
我添加8.8.1 一直有问题 链接不上啦,超时啦,等等 花了我很多时间了

2,在你底层lib build.gradle(你的module)中添加
applyplugin:'com.jakewharton.butterknife'
dependencies {
api"com.jakewharton:butterknife:$versions.butterKnife"
annotationProcessor"com.jakewharton:butterknife-compiler$versions.butterKnife"
}
这三句话 就可以了
3.在主app build.gradle中添加引用
dependencies {
annotationProcessor"com.jakewharton:butterknife-compiler:$versions.butterKnife"
}
这样就可以了

主 app 是顶层 。。。
其他module 是引用的 。。