Android Studio Arctic Fox添加RecyclerView依赖后Androidx类无法解析报错
问题解决方案
1. 校验compileSdk版本兼容性
- 打开app模块下的
build.gradle文件,查看compileSdk取值,androidx.recyclerview:recyclerview:1.2.1要求最低compileSdkVersion 31,如果你的项目compileSdk低于31,请将其升级到31及以上版本。
2. 检查constraintlayout依赖是否存在
- 本次报错包含constraintlayout类找不到的问题,大概率是添加recyclerview依赖时意外覆盖/移除了原有constraintlayout依赖,请在app模块
build.gradle的dependencies块中手动添加constraintlayout依赖:
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
3. 清理并重新构建项目
- 点击顶部菜单栏
Build > Clean Project,等待清理完成后点击Build > Rebuild Project - 如果仍有报错,执行gradle同步:点击顶部工具栏的
Sync Project with Gradle Files按钮
4. 清除缓存(可选,如以上步骤无效时执行)
- 点击顶部菜单栏
File > Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart等待Android Studio重启后自动同步项目
内容的提问来源于stack exchange,提问作者tfn
相关产品推荐
相关产品推荐

