我想在我的项目中使用 CardView,但它显示错误:无法解决:cardview Affected Modules:app,为什么?我检查了依赖项并更新了 android studio,但它再次显示相同的错误
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.dubsmash.volley:library:2.0.1'
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.3.0-alpha01'
implementation 'androidx.core:core-ktx:1.4.0-alpha01'
implementation 'androidx.cardview:cardview:1.0.0'
}
我无法添加卡片 View 。布局是:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="76dp"
android:fontFamily="@font/chewy"
android:text="@string/title"
android:textSize="36sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.525"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
最佳答案
只需删除它们
仅使用这 3 个,您就可以同时使用 RecyclerView 和 CardView 以及一个加号:ConstraintLayout
implementation 'androidx.appcompat:appcompat:1.1.0-alpha04'
implementation 'androidx.core:core-ktx:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
或/与
添加 Material 组件:
implementation 'com.google.android.material:material:1.2.0-alpha06'
关于android - 错误 : Failed to resolve: cardview Affected Modules: app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62308850/