初学Kotlin使用ButterKnife遇到的问题

我先来个在kotlin中正规的写一个点击事件app

 

首先要在onCreate方法的setContentView以后设置绑定BufferKnike.bind(this)工具

而后@BindView(id) lateinit var button : Buttonthis

而后Onclick(id) fun onClick(){ ....  }插件

 

而后就一直无效,摸不着头脑,百度了好久,也没发现问题事件

而后我看了我引用的ButterKnike it

annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'

感受不对

看到了这句话: 在 Kotlin 中添加依赖与 Java 中相似,仅须要使用 Kotlin 注解处理工具(Kotlin Annotation processing tool,kapt)替代 annotationProcessor 便可。

加入
kapt "com.jakewharton:butterknife-compiler:8.8.1"
以后提示再依赖插件:
apply plugin: 'kotlin-kapt'在 Kotlin 中则须要添加 kotlin-kapt 插件激活 kapt,并使用 kapt 替换 annotationProcessor:特别提示:kapt 也可以处理 Java 文件,因此不须要再保留 annotationProcessor 的依赖。
相关文章
相关标签/搜索