'Android - Motion Layout Syntax Error: No Valid LayoutDescription

I am getting the following error when I switch to MotionLayout from ConstraintLayout. I have tried rebuilding the project but no use.

Error

Layout Code:

<androidx.constraintlayout.motion.widget.MotionLayout 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:id="@+id/fragment_death_motion_layout"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center"
android:layout_marginHorizontal="16dp"
android:background="@drawable/black_gray_gradient"
android:visibility="visible"
app:layoutDescription="@xml/dialog_fragment_death_scene"
tools:context=".ui.DeathDialogFragment">


<TextView
    android:id="@+id/game_over_text_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="32dp"
    android:layout_marginEnd="16dp"
    android:text="@string/game_over"
    android:textAppearance="@style/TextAppearance.AppCompat.Display1"
    android:textColor="@android:color/white"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.496"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

<TextView
    android:id="@+id/score_tv"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="24dp"
    android:text="666"
    android:textAppearance="@style/TextAppearance.AppCompat.Display3"
    android:textColor="@android:color/white"
    app:layout_constraintEnd_toEndOf="@+id/game_over_text_tv"
    app:layout_constraintStart_toStartOf="@+id/game_over_text_tv"
    app:layout_constraintTop_toBottomOf="@+id/game_over_text_tv" />

</androidx.constraintlayout.motion.widget.MotionLayout>



Solution 1:[1]

You can close the layout file's tab and reopen it.

Solution 2:[2]

I am getting this error whenever I change the constraint layout to motion layout by editing the XML manually.

However, restarting the Android Studio has solved the problem for me.

Edit: Cutting and pasting the app:layoutDescription attribute also seems to be fixing the issue if it repeates after you've got it working: app:layoutDescription="@xml/dialog_fragment_death_scene"

Solution 3:[3]

Make sure the <MotionScene...> xml file is in the same module as your layout xml file

Solution 4:[4]

Invalidate Caches and Restart helped me

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 hoford
Solution 2
Solution 3 Izzy Stannett
Solution 4 Hayk Mkrtchyan