MotionLayout - annoying debug error in the log: "no widget for <view id> (<view type>)"

Viewed 511

I've been using MotionLayout for a while now, and it's been an absolute delight.

But I've been facing a pollution problem I'd like to know how can I get rid of.

Basically I'm getting bombarded the following kinds of errors in the logs, despite not seeing any issue with my MotionLayout-powered layouts:

2020-04-02 23:32:35.709 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  callLog (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.709 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  callLog (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.709 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  spaceTop (android.widget.Space)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  spaceTop (android.widget.Space)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  callLogExpanded (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  callLogExpanded (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  callLogDeleteIcon (androidx.appcompat.widget.AppCompatImageView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  callLogDeleteIcon (androidx.appcompat.widget.AppCompatImageView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  guidelineLeft (androidx.constraintlayout.widget.Guideline)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  guidelineLeft (androidx.constraintlayout.widget.Guideline)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  callLog (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  callLog (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  spaceTop (android.widget.Space)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  spaceTop (android.widget.Space)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1959)no widget for  callLogExpanded (com.google.android.material.card.MaterialCardView)
2020-04-02 23:32:35.710 12500-12500/cz.nn.calllog E/MotionLayout: .(MotionLayout.java:1967)no widget for  callLogExpanded (com.google.android.material.card.MaterialCardView)

Inspecting the build() method of MotionLayout.java didn't help me much in understanding the corner cases that get to yield these errors. My scenes don't have references to all the children of a given MotionLayout, but only to the children that get animated instead. But this log errors reference both children that are completely defined in the scene (meaning they have Constraints defined for all the ConstraintSets) as well as those children that have no reference because they don't have changes in their constraints (whose definitions I've left out of the scene files precisely because MotionLayout accepts this convenience).

I'm using a RecyclerView where each children has a view with an embedded MotionLayout. I'm suspecting having both of them together is somehow yield this issue... can anyone tell me if this is potentially something I should worry about? So far I've been ignoring it since as I said, I see really no impact in the overall functionality of the layouts that rely on this class.

This has all been tested on an emulator running Android 10.

Thank you in advance for any insight you might provide!

1 Answers

This happened to me just now. The issue was that I was attempting to set a transition state in my fragment using the wrong MotionLayout (I also have nested MotionLayouts).

Instead of calling binding.secondMotionLayout.root.setState(...), I was calling binding.firstMotionLayout.root.setState(...) and attempting to reference the ConstraintSets of the second MotionLayout`.

Maybe you are doing something similar with your RecyclerView? I would make sure to properly reference the MotionLayout of each item in your RecyclerView. Depending on how you've implemented it, it would be inside the ViewHolder.

Related