Why is android ConstraintLayout crashing on Samsung devices only with error on Guidelines?

I have a complex fragment layout that is crashing on specific devices. This gives the following error being thrown on applyConstraintsFromLayoutParams() method on ConstraintLayout class.

java.lang.ClassCastException: androidx.constraintlayout.solver.widgets.ConstraintWidget cannot be cast to androidx.constraintlayout.solver.widgets.Guideline
    at androidx.constraintlayout.widget.ConstraintLayout.applyConstraintsFromLayoutParams(ConstraintLayout.java:1278)
    at androidx.constraintlayout.widget.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:1253)
    at androidx.constraintlayout.widget.ConstraintLayout.updateHierarchy(ConstraintLayout.java:1149)
    at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1685)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:24974)
    at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:792)
    at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:583)
    at androidx.constraintlayout.solver.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:355)
    at androidx.constraintlayout.solver.widgets.analyzer.Direct.solveVerticalMatchConstraint(Direct.java:636)
    at androidx.constraintlayout.solver.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:407)
    at androidx.constraintlayout.solver.widgets.analyzer.Direct.verticalSolvingPass(Direct.java:446)
    at androidx.constraintlayout.solver.widgets.analyzer.Direct.solvingPass(Direct.java:178)
    at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:642)
    at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:159)
    at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:290)
    at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119)
    at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1578)
    at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1690)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:825)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:704)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:825)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:704)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at com.android.internal.policy.DecorView.onMeasure(DecorView.java:992)
    at android.view.View.measure(View.java:24974)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:3314)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:2034)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2336)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1894)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8553)

2021-01-18 17:49:17.561 25981-25981/com.nauv.fps.android E/AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer.doFrame(Choreographer.java:696)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7050)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteIout nit.java:965)

I am currently using version 2.0.4 as shown on my gradle

implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

The layout is a has a lot of views but in case this is needed I will post the overall layout.

Source: Android Questions

2 thoughts on - Why is android ConstraintLayout crashing on Samsung devices only with error on Guidelines?

LEAVE A COMMENT