ERROR.Failed resolve: cardview 解决失败:cardview 受影响的模块:app。

问题描述 投票:0回答:1

我想在我的项目中使用CardView,但它显示ERROR.Failed resolve: cardview Affect Modules: app,Why? Failed to resolve: cardview 受影响的模块:app,Why?I checked dependencies and updated android studio but again it shows same error.

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'

}

我不能加卡视。布局是。

<?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>
android android-studio android-cardview cardview
1个回答
1
投票

删除它们

只要有了这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'

ORAND

添加MaterialComponents。

implementation 'com.google.android.material:material:1.2.0-alpha06'

1
投票

由于AndroidX仍然有一些奇怪的bug,你可以通过更新android studio到最新版本来解决。

你也可以使用 android.enablejetifierfalsegradle.properties 但你将不得不使用androidx库。

© www.soinside.com 2019 - 2024. All rights reserved.