我的 xml 代码中有一个错误停止了所有应用程序

i have an error in my xml code that stop all the app

我的代码有误

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    implementation 'androidx.cardview:cardview:1.0.0'

和 xml

<android.support.v7.widget.CardView
            android:id="@+id/card_view"
            android:layout_width="match_parent"
            android:layout_height="293dp"
            app:cardBackgroundColor="@color/card"
            app:cardCornerRadius="10dp"
            app:cardElevation="5dp"
            app:cardUseCompatPadding="true">

            <TextView
                android:id="@+id/textView4"
                android:layout_width="432dp"
                android:layout_height="510dp"
                android:text="TextView" />

            <WebView
                android:id="@+id/webview"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:ignore="WebViewLayout" />
        </android.support.v7.widget.CardView>

有了这行代码,应用程序停止了,我只尝试使用依赖项行,但我没有放置 XML 的代码行,只有依赖项实现 cardview 行和 hid 没有停止,但是当我为 XML 文件放置代码行时,应用程序停止。

您的 gradle 文件中有 CardViewandroidx 版本:

implementation 'androidx.cardview:cardview:1.0.0'

但是您在布局文件中使用了旧版本的 CardView

<android.support.v7.widget.CardView ... />

你必须在两者中使用相同的版本。所以用这个替换布局文件中的标签:

<androidx.cardview.widget.CardView ... />