我正在尝试使用最近购买的RFID扫描仪提供的SDK。 我正在尝试运行给定的示例代码,但无法编译。编译时出现以下错误:
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
我已经在类似的帖子中尝试了所有解决方案,并且我很确定自己已经正确安装了支持库。
这是我在build.gradle(app)中的所有依赖项
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation project(':Rfid.AsciiProtocol-Library')
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:recyclerview-v7:26.0.0'
}
我是Android Studio的新手,正如我所说,我几乎尝试了所有类似问题的答案,但没有任何效果。欢迎任何帮助:)
非常感谢
西里尔
答案 0 :(得分:2)
您应将android support recyclerview替换为androidx
implementation 'androidx.recyclerview:recyclerview:1.0.0'
并且您可以删除'com.android.support:appcompat-v7:+'依赖性,因为您已经使用
导入了它implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
答案 1 :(得分:1)
这让我沮丧了好几个小时,因为这里给出的答案缺失太多了。
在gradle的依赖中: 导入:
implementation 'androidx.recyclerview:recyclerview:1.0.0'
点击gradle sync(应该是弹出的页面顶部的一个栏
然后在您实际使用 RecyclerView 类的 java 文件中,导入:
import androidx.recyclerview.widget.RecyclerView;
你就完成了