Butterknife 配置依赖

配合插件 Zelezny

ButterKnife 8.0.1在使用方式上较上个版本有了较大的变化: 增加了资源绑定,并且将 compiler 分离了出来,引用方式做了改变。
首先我们看Butter Knife官网的教程:
[html]   view plain   copy  
派生到我的代码片
  1. buildscript {  
  2.   repositories {  
  3.     mavenCentral()  
  4.    }  
  5.   dependencies {  
  6.     classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  
  7.   }  
  8. }  
  9.   
  10. apply plugin: 'com.neenbedankt.android-apt'  
  11.   
  12. dependencies {  
  13.   compile 'com.jakewharton:butterknife:8.0.1'  
  14.   apt 'com.jakewharton:butterknife-compiler:8.0.1'  
  15. }  

按照上述配置,你可能会出现编译上的问题,如找不到com.neenbedankt. Android -apt等问题。
经过测试,总算搞清楚了问题。
首先看下面的工程目录:


有两个build.gradle文件,分别是:RetrofitDemo/build.gradle和app/build.gradle,他们的区别详见: http://stormzhang.com/devtools/2014/12/18/android-studio-tutorial4/
下面进入正题。
RetrofitDemo/build.gradle配置文件中添加:
[html]   view plain   copy  
派生到我的代码片
  1. buildscript {  
  2.     repositories {  
  3.         jcenter()  
  4.     }  
  5.     dependencies {  
  6.         classpath 'com.android.tools.build:gradle:2.1.0'  
  7.         classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  
  8.     }  
  9. }  

也就是我们修改gradle版本的那个build文件。

app/build.gradle配置文件中如下:
[html]   view plain   copy  
派生到我的代码片
  1. apply plugin: 'com.android.application'  
  2. apply plugin: 'com.neenbedankt.android-apt'  
  3.   
  4. android {  
  5.     compileSdkVersion 23  
  6.     buildToolsVersion "23.0.3"  
  7.   
  8.     defaultConfig {  
  9.         applicationId "com.baidu.retrofitdemo"  
  10.         minSdkVersion 16  
  11.         targetSdkVersion 23  
  12.         versionCode 1  
  13.         versionName "1.0"  
  14.     }  
  15.     buildTypes {  
  16.         release {  
  17.             minifyEnabled false  
  18.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'  
  19.         }  
  20.     }  
  21.   
  22.   
  23. }  
  24.   
  25. dependencies {  
  26.     compile fileTree(dir: 'libs', include: ['*.jar'])  
  27.     testCompile 'junit:junit:4.12'  
  28.     compile 'com.android.support:design:23.3.0'  
  29.     compile 'com.android.support:appcompat-v7:23.3.0'  
  30.     compile 'com.squareup.okhttp3:okhttp:3.2.0'  
  31.     compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'  
  32.     compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta3'  
  33.     compile 'com.jakewharton:butterknife:8.0.1'  
  34.     apt 'com.jakewharton:butterknife-compiler:8.0.1'  
  35. }  

如此,clean下就可以


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值