Bur*_*hid 3 android android-activity android-studio butterknife
昨天,我正在使用 Butterknife 进行正在进行的项目。但是突然它停止工作了。它ButterKnife.bind(this)无法绑定视图,因此所有视图都会抛出NullPointerException。我不明白发生了什么,突然它停止工作了。它奇怪的情况
以下是我已经做过但不起作用的几点
以下是我正在使用的版本
ext {
// sdk and tools
minSdkVersion = 21
targetSdkVersion = 27
compileSdkVersion = 27
buildToolsVersion = '26.0.2'
// dependencies versions
supportLibraryVersion = '27.0.0'
playServicesVersion = '10.2.4'
butterKnifeVersion = '8.8.1'
retrofitVersion = '2.3.0'
}
Run Code Online (Sandbox Code Playgroud)
在过去的 8 个小时里,我一直在为这个愚蠢的问题而苦恼。如果有人能提供帮助,我们将予以拨款
最后我找到了解决方案。Ii是由于Kotlin Plugin。自从我在 Android Studio 3.0 中更新了 Kotlin 插件后就发生了这种情况
如果您使用 Kotlin 那么将annotationProcessor无法工作,您需要使用kapt
所以替换这个
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
Run Code Online (Sandbox Code Playgroud)
有了这个
compile 'com.jakewharton:butterknife:8.8.1'
kapt'com.jakewharton:butterknife-compiler:8.8.1'
Run Code Online (Sandbox Code Playgroud)
它将解决问题
| 归档时间: |
|
| 查看次数: |
911 次 |
| 最近记录: |