Element LinearLayout is not allowed in CardView
So, a collection of suggestions, just to be sure:
- restart AS
- invalidating Caches & restart
- Check if the right dependencies are added
- clean & rebuild of project
- try same code in another file/project
- trying to find a backup of your project
- maybe computer reboot
Check if the Gradle dependency is added properly for the CardView.
In build.gradle
implementation 'com.android.support:cardview-v7:28.0.0'
And then in the XML
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:background="#fff"
app:cardCornerRadius="2dp"
android:elevation="2dp">
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="@+id/textView" />
</androidx.cardview.widget.CardView>
Just replace android.support.v7.widget.CardView
with androidx.cardview.widget.CardView