问题描述:
在使用 Android studio 2021.1.1 版本时出现添加 “ recyclerview-v7 库 ”报错
原因分析:
在使用 Android studio 2021.1.1版本中,由于更新了多个补丁和版本迭代,在项目需要添加“recyclerview-v7”库时,会找不到原来版本的添加窗口。原因是在 Android studio 2021.1.1 版本中对于“ recyclerview-v7 库 ”已经存在,并不需要再次下载。
解决方案:
(写在前面):你可以先把项目名所需要的包创建好,也就是点击项目名的错误,更新项目包。然后再去点击出现 “ v7 " 报错的地方,选择 “ Optimize imports ”,可以先尝试,成功即可。
1. 如果出现该类报错,可以尝试先打开你 Android 项目 的 Gradle Scripts 下的 build.gradle(Module:Contact.app)
2. 找到 dependencies{},然后再dependencies{}下添加一行代码: implementation 'androidx.recyclerview:recyclerview:1.0.0' ,也就是下面代码段中间空格后的那行代码。
dependencies { implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.appcompat:appcompat:1.3.0' implementation 'com.google.android.material:material:1.4.0' implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.recyclerview:recyclerview:1.0.0' testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.1.3' androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' }
3. 然后在代码框右上角点击Sync Now,随后对你项目代码有关“ recyclerview-v7 库 ”报错的地方一 一调试,应该就能够解决。错误不一定一致,所以不能保证解决,耐心是解决报错的最好方法。
下图是对解决方案的图文解释,方便读者能够有更好的观看体验。
文章末尾
感谢观看,欢迎建议!!!
三连是最大的支持!!!