将约束布局从1.1.2升级到1.1.3后android应用崩溃

时间:2019-11-15 22:13:24

标签: android android-constraintlayout system-error

在从'com.android.support.constraint:constraint-layout:1.1.2'升级到'com.android.support.constraint:constraint-layout:1.1.3'之前,应用正常运行

我没有线路错误,只是这个系统错误:

java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.constraint.ConstraintLayout$LayoutParams
    at android.support.constraint.ConstraintLayout.getTargetWidget(ConstraintLayout.java:1144)
    at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:1028)
    at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:803)
    at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1561)
    at android.view.View.measure(View.java:24973)
    at android.support.constraint.ConstraintLayout.internalMeasureChildren(ConstraintLayout.java:1227)
    at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1572)
    at android.view.View.measure(View.java:24973)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
    at android.view.View.measure(View.java:24973)
    at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1059)
    at android.view.View.measure(View.java:24973)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:7139)

有人可以帮助我解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

似乎您将com.android.support.constraint作为依赖项,而不是androidx.constraintlayout.

为我而改变

implementation 'com.android.support.constraint:constraint-layout:1.1.3'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

解决了该问题。