Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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>

like image 238
DeveloperKurt Avatar asked Sep 08 '20 10:09

DeveloperKurt


People also ask

What is MotionLayout in Android?

MotionLayout is a layout type that helps you manage motion and widget animation in your app. MotionLayout is a subclass of ConstraintLayout and builds upon its rich layout capabilities. As part of the ConstraintLayout library, MotionLayout is available as a support library and is backwards-compatible to API level 14.


2 Answers

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

like image 187
hoford Avatar answered Oct 09 '22 09:10

hoford


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"

like image 27
DeveloperKurt Avatar answered Oct 09 '22 10:10

DeveloperKurt