Kotlin 之 ButterKnife

2019-05-21  本文已影响0人  冰珊孤雪

使用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, 完成。

上一篇 下一篇

猜你喜欢

热点阅读