我先來個在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 的依賴。