'Undeclared namespace prefix "app" (for attribute "cardCornerRadius") Android?

Undeclared namespace prefix "app" (for attribute "cardCornerRadius") at [row,col {unknown-source}]: [16,38]

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center">

    <androidx.cardview.widget.CardView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/cardView"
        android:layout_width="120dp"
        android:layout_height="120dp"
        app:cardCornerRadius="20dp"
        app:cardElevation="20dp">

        <ImageButton
            android:id="@+id/imageButton"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FFC6C6"
            android:scaleType="centerCrop"
            app:srcCompat="@drawable/ic_launcher_background" />
    </androidx.cardview.widget.CardView>
</LinearLayout>


Solution 1:[1]

Remove the first 2 lines from the Cardview. Then go to the last line and press Alt+Enter and choose the first option from the popup to refactor.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Syed Faizan Ali