使用Java
方式集成 ButterKnife, 在gradle
配置如下:
dependencies {
implementation 'com.jakewharton:butterknife:10.1.0'
// If you are using Kotlin, replace annotationProcessor with kapt.
// annotationProcessor rootProject.ext.dependencies["butterknife-compiler"]
kapt 'com.jakewharton:butterknife-compiler:10.1.0'
}
使用kotlin
集成,在gradle
配置如下:
dependencies {
implementation 'com.jakewharton:butterknife:10.1.0'
kapt 'com.jakewharton:butterknife-compiler:10.1.0'
}
注意
:
使用kotlin
方式集成,按上面配置好之后,sync
之后,提示错误。
[Gradle DSL method not found: 'kapt()']
解决方法是:在build.gradle
文件头添加:
apply plugin: 'kotlin-kapt'
添加完成后,重新sync
, 完成。
网友评论