同时使用AndroidX库和bufferknife库报 package android.support.annotation does not exist 错误
16lz
2021-01-25
Android项目同时使用AndroidX库和bufferknife库报错: package android.support.annotation does not exist
原因:谷歌使用AndroidX扩展库代替老的Android支持库,androidx库中annotation.jar包的包名由android.support.annotation变为androidx.annotation,而bufferknife8.8.1之前一直调用的是android.support.annotation支持库,而使用androidx代替android.support后,导致annotation.jar里的一些类找不到,比如:
解决办法:应调用bufferknife:9.0.0-rc1以上版本,在Module build.gradle里修改:
dependencies { implementation 'com.jakewharton:butterknife:10.0.0' annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'}
在Project build.gradle里修改:
dependencies { classpath 'com.android.tools.build:gradle:3.3.0' classpath 'com.jakewharton:butterknife-gradle-plugin:10.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }
可以参考GitHub上的解决方案:https://github.com/JakeWharton/butterknife/issues/1296
如有不足欢迎指正。于2018年11月9日
更多相关文章
- 高级Redis应用进阶课 一站式Redis解决方案
- 【Android】 Eclipse : ERROR: Unknown option '--no-crunch'的
- android常见异常
- 关于android studio IDE升级到3.0之后出现的配置和项目兼容问题
- Android(安卓)MediaPlayer播放异常问题汇总
- android全格式多媒体播放器(三:基于ffmpeg架构的具体实现)
- activity打开时不自动弹出软键盘
- Android(安卓)Studio的APP目录下的build.gradle的配置说明
- android 开发故障记录