使用butterKnife 8.0.1 构建的项目无法正常运行

在使用 butterKnife 注入视图后,启动项目后无法触发点击事件,目测应该是没有绑定成功,也就是插件没有正常运行,遂在简书上找到了这篇文章

http://www.jianshu.com/p/bf9018c1a7f6

还有在csdn上的这篇,

http://blog.csdn.net/jdsjlzx/article/details/51354433

具体解决思路是:

1.  ButterKnife 8.0.1在使用方式上较上个版本有了较大的变化:增加了资源绑定,并且将 compiler 分离了出来,引用方式做了改变。

所以除了依赖包除了添加 compile 'com.jakewharton:butterknife:8.0.1'

还应按官网的添加  apt 'com.jakewharton:butterknife-compiler:8.0.1'

2.这是可能会提示 找不到com.neenbedankt.Android-apt等问题

官网是这样介绍Android-apt 的

The android-apt plugin assists in working with annotation processors in combination with Android Studio. 

如何加入和使用呢,是这样的

Add the following to your build script to use the plugin:

buildscript

{

repositories{

mavenCentral()

}

dependencies{                                                  

// replace with the current version of the Android plugin

classpath'com.android.tools.build:gradle:1.3.0'

// the latest version of the android-apt plugin

classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'

}

}

applyplugin:'com.android.application'

applyplugin:'com.neenbedankt.android-apt'

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容