美文网首页
使用butterKnife 8.0.1 构建的项目无法正常运行

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

作者: 抓兔子的猫 | 来源:发表于2016-05-31 09:47 被阅读339次

在使用 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'

相关文章

网友评论

      本文标题:使用butterKnife 8.0.1 构建的项目无法正常运行

      本文链接:https://www.haomeiwen.com/subject/kiucdttx.html