title: Motionlayout: WARNING could not find view id -1
body: <p>My problem is, that I constantly get the warning <code>W/MotionLayout: WARNING could not find view id -1</code>. Because of this, my MotionLayout is really laggy and nearly jumps from the <code>expanded state</code> to the <code>collapsed state</code>. After waiting a couple of seconds, the animation starts getting better (no jumping / laggs anymore), but the warning remains.</p>
  <h2>Base XML</h2>
  <pre><code>&lt;layout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;&gt;
  
      &lt;data&gt;
          &lt;variable
              name=&quot;product&quot;
              type=&quot;com.example.app.framework.datasource.models.product.Product&quot; /&gt;
      &lt;/data&gt;
  
      &lt;androidx.constraintlayout.motion.widget.MotionLayout
          android:id=&quot;@+id/shop_motion_layout&quot;
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;
          app:layoutDescription=&quot;@xml/shop_item_content_scene&quot;
          app:showPaths=&quot;true&quot;
          tools:context=&quot;.framework.ui.view.fragments.shop.ShopItemFragment&quot;&gt;
  
          &lt;com.google.android.material.appbar.MaterialToolbar
              android:id=&quot;@+id/shop_toolbar&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:theme=&quot;@style/ThemeOverlay.AppCompat.Light&quot;
              app:menu=&quot;@menu/shop_item_toolbar&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/product_image&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;142dp&quot;
              android:layout_marginStart=&quot;72dp&quot;
              android:layout_marginTop=&quot;@dimen/standard8dpMargin&quot;
              android:layout_marginEnd=&quot;72dp&quot;
              android:adjustViewBounds=&quot;true&quot;
              android:contentDescription=&quot;@null&quot;
              android:fitsSystemWindows=&quot;true&quot;
              app:loadImage=&quot;@{product.images[0]}&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@id/shop_toolbar&quot; /&gt;
  
          &lt;com.google.android.material.textview.MaterialTextView
              android:id=&quot;@+id/product_name&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginTop=&quot;@dimen/big16dpMargin&quot;
              android:layout_marginBottom=&quot;12dp&quot;
              android:ellipsize=&quot;end&quot;
              android:fontFamily=&quot;sans-serif-medium&quot;
              android:maxLines=&quot;2&quot;
              android:text=&quot;@{product.name}&quot;
              android:textAlignment=&quot;textStart&quot;
              android:textColor=&quot;@color/color_text_dark&quot;
              android:textSize=&quot;@dimen/textHeadlineNormal1&quot;
              app:layout_constraintBottom_toTopOf=&quot;@id/scrollview_shop&quot;
              app:layout_constraintEnd_toEndOf=&quot;@id/barrier&quot;
              app:layout_constraintStart_toStartOf=&quot;@id/margin_left&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/product_image&quot;
              tools:text=&quot;Long text to test some stuff etc. bla bla&quot; /&gt;
  
          &lt;com.google.android.material.button.MaterialButton
              android:id=&quot;@+id/btn_shop&quot;
              style=&quot;@style/Widget.MaterialComponents.Button.Icon&quot;
              android:layout_width=&quot;56dp&quot;
              android:layout_height=&quot;56dp&quot;
              android:layout_marginEnd=&quot;16dp&quot;
              android:backgroundTint=&quot;@color/color_btn_blue&quot;
              android:insetLeft=&quot;0dp&quot;
              android:insetTop=&quot;0dp&quot;
              android:insetRight=&quot;0dp&quot;
              android:insetBottom=&quot;0dp&quot;
              android:padding=&quot;0dp&quot;
              app:icon=&quot;@drawable/ic_shopping_cart_filled&quot;
              app:iconGravity=&quot;textStart&quot;
              app:iconPadding=&quot;0dp&quot;
              app:layout_constraintBottom_toTopOf=&quot;@id/scrollview_shop&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;@id/scrollview_shop&quot;
              app:shapeAppearanceOverlay=&quot;@style/ShapeAppearanceOverlay.Example.Button.Circle&quot; /&gt;
  
          &lt;!-- My scrollview --&gt;
          &lt;androidx.core.widget.NestedScrollView
              android:id=&quot;@+id/scrollview_shop&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;0dp&quot;
              android:fillViewport=&quot;true&quot;
              app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@id/product_name&quot;&gt;
  
              &lt;androidx.constraintlayout.widget.ConstraintLayout
                  android:id=&quot;@+id/someID&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;&gt;
  
                  &lt;com.google.android.material.textview.MaterialTextView
                      android:id=&quot;@+id/product_article_number&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginTop=&quot;@dimen/standard8dpMargin&quot;
                      android:text=&quot;FISCH&quot;
                      android:textAlignment=&quot;textStart&quot;
                      android:textColor=&quot;@color/color_text_gray&quot;
                      android:textDirection=&quot;locale&quot;
                      android:textSize=&quot;@dimen/textDescriptionNormal2&quot;
                      android:textStyle=&quot;normal&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintTop_toTopOf=&quot;parent&quot;
                      tools:text=&quot;A 1234567&quot; /&gt;
  
                  &lt;com.google.android.material.textview.MaterialTextView
                      android:id=&quot;@+id/tv_mwst_disclaimer&quot;
                      android:layout_width=&quot;wrap_content&quot;
                      android:layout_height=&quot;wrap_content&quot;
                      android:layout_marginTop=&quot;@dimen/standard8dpMargin&quot;
                      android:text=&quot;SEIFE&quot;
                      android:textAlignment=&quot;textStart&quot;
                      android:textColor=&quot;@color/color_text_mwst&quot;
                      android:textDirection=&quot;locale&quot;
                      android:textSize=&quot;@dimen/textDescriptionNormal4&quot;
                      android:textStyle=&quot;italic&quot;
                      app:layout_constraintStart_toStartOf=&quot;parent&quot;
                      app:layout_constraintTop_toBottomOf=&quot;@id/product_article_number&quot;
                      tools:text=&quot;PREIS&quot; /&gt;
  
              &lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;
          &lt;/androidx.core.widget.NestedScrollView&gt;
  
          &lt;androidx.constraintlayout.widget.Barrier
              android:id=&quot;@+id/barrier&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              app:barrierDirection=&quot;left&quot;
              app:constraint_referenced_ids=&quot;btn_shop&quot; /&gt;
  
          &lt;androidx.constraintlayout.widget.Guideline
              android:id=&quot;@+id/margin_left&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:orientation=&quot;vertical&quot;
              app:layout_constraintGuide_begin=&quot;@dimen/big16dpMargin&quot; /&gt;
  
      &lt;/androidx.constraintlayout.motion.widget.MotionLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  <h2>ContentScene XML</h2>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;MotionScene xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:motion=&quot;http://schemas.android.com/tools&quot;&gt;
  
      &lt;Transition
          app:constraintSetEnd=&quot;@id/collapsed&quot;
          app:constraintSetStart=&quot;@id/expanded&quot;&gt;
  
          &lt;OnSwipe
              motion:dragDirection=&quot;dragUp&quot;
              app:onTouchUp=&quot;stop&quot;
              motion:touchAnchorId=&quot;@id/scrollview_shop&quot;
              motion:touchAnchorSide=&quot;top&quot; /&gt;
  
          &lt;KeyFrameSet&gt;
              &lt;KeyAttribute
                  app:motionTarget=&quot;@id/product_image&quot;
                  app:framePosition=&quot;40&quot;
                  android:alpha=&quot;0.0&quot; /&gt;
          &lt;/KeyFrameSet&gt;
      &lt;/Transition&gt;
  
      &lt;ConstraintSet android:id=&quot;@+id/expanded&quot; /&gt;
  
      &lt;ConstraintSet android:id=&quot;@+id/collapsed&quot;&gt;
          &lt;Constraint
              android:id=&quot;@id/product_image&quot;
              android:layout_height=&quot;?attr/actionBarSize&quot;
              android:layout_marginStart=&quot;56dp&quot;
              android:layout_marginEnd=&quot;56dp&quot;
              android:alpha=&quot;0.0&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
          &lt;Constraint
              android:id=&quot;@id/product_name&quot;
              android:layout_width=&quot;0dp&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginStart=&quot;56dp&quot;
              android:layout_marginEnd=&quot;@dimen/standard8dpMargin&quot;
              android:scaleX=&quot;0.925&quot;
              android:scaleY=&quot;0.925&quot;
              app:layout_constraintBottom_toBottomOf=&quot;@id/shop_toolbar&quot;
              app:layout_constraintTop_toTopOf=&quot;@id/shop_toolbar&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintEnd_toEndOf=&quot;@id/barrier&quot; /&gt;
  
          &lt;Constraint
              android:id=&quot;@id/btn_shop&quot;
              android:layout_marginEnd=&quot;@dimen/big16dpMargin&quot;
              android:layout_width=&quot;56dp&quot;
              android:layout_height=&quot;56dp&quot;
              app:layout_constraintBottom_toBottomOf=&quot;@id/shop_toolbar&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintTop_toBottomOf=&quot;@+id/product_name&quot; /&gt;
      &lt;/ConstraintSet&gt;
  
  &lt;/MotionScene&gt;
  </code></pre>
  <h2>Fragment</h2>
  <pre><code>class ShopItemFragment : Fragment(R.layout.fragment_shop_item) {
      private val productArgs by navArgs&lt;ShopItemFragmentArgs&gt;()
  
      override fun onCreateView(
          inflater: LayoutInflater,
          container: ViewGroup?,
          savedInstanceState: Bundle?
      ): View? = FragmentShopItemBinding.inflate(inflater, container, false).apply {
          product = productArgs.product
      }.root
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
          initToolbar()
      }
  
      private fun initToolbar() = shop_toolbar.apply {
          setupWithNavController(findNavController(), AppBarConfiguration(findNavController().graph))
      }
  }
  </code></pre>
  <h2>Expanded</h2>
  <p><a href="https://i.stack.imgur.com/pJHEN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pJHEN.png" alt="Expanded" /></a></p>
  <h2>Collapsed</h2>
  <p><a href="https://i.stack.imgur.com/1TnXX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1TnXX.png" alt="Collapsed" /></a></p>
  <h2>EDIT</h2>
  <p>I've tried to debug my code as good as I can and I found following: In my view, the <code>mConstraintSetId</code> has the value <code>-1</code>, and I think that logcat is warning me about that. How can I change this value or to say better: Why is this value -1?
  <a href="https://i.stack.imgur.com/g9qmn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g9qmn.png" alt="enter image description here" /></a></p>