android - 错误 : Failed to resolve: cardview Affected Modules: app

标签 android android-studio android-cardview cardview

我想在我的项目中使用 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/

相关文章:

Java错误: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference

android - 为什么 Firebase 和 Google Analytics 指标不匹配?

android - 在 android studio 中更改 gradle 构建目录?

安卓支持-v7 CardView : Header textview with other background color does not extend until the edges

java - "int pix = (0xff & ((int) first[ij])); "是什么意思?

java - 使用 SSH 将文件从 Android 应用程序发送到树莓派

java - 是否有类似于 <android.support.v7.widget.CardView> 的 <CardView> 标签?

java - Cardview 没有占据全宽(从左边裁剪 2%)

Android Studio 2.2.2 更新后渲染预览报错 "Unable to locate mode 0"

android-studio - 复制静态文件以在gradle中构建输出文件夹