Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

constraint:constraint-layout:1.1.0 java.lang.AssertionError: LEFT at android.support.constraint.solver.widgets.Guideline.getAnchor(Guideline.java:159) #51

Open
hereisderek opened this issue May 1, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@hereisderek
Copy link

commented May 1, 2018

with

implementation "com.android.support.constraint:constraint-layout:1.1.0"
implementation "com.android.support.constraint:constraint-layout-solver:1.1.0"

getting a run time error:

 Process: com.example.derek.trademeapi, PID: 14475
    java.lang.AssertionError: LEFT
        at android.support.constraint.solver.widgets.Guideline.getAnchor(Guideline.java:159)
        at android.support.constraint.solver.widgets.ConstraintWidget.immediateConnect(ConstraintWidget.java:1578)
        at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:978)
        at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:793)
        at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1540)
        at android.view.View.measure(View.java:22944)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6729)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
        at android.support.v7.widget.CardView.onMeasure(CardView.java:258)
        at android.view.View.measure(View.java:22944)
        at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:8994)
        at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1585)
        at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1519)
        at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:614)
        at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3812)
        at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3529)
        at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:4082)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.support.design.widget.HeaderScrollingViewBehavior.layoutChild(HeaderScrollingViewBehavior.java:132)
        at android.support.design.widget.ViewOffsetBehavior.onLayoutChild(ViewOffsetBehavior.java:42)
        at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild(AppBarLayout.java:1361)
        at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:894)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1790)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1634)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1543)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1790)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1634)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1543)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
        at com.android.internal.policy.DecorView.onLayout(DecorView.java:757)
        at android.view.View.layout(View.java:20449)
        at android.view.ViewGroup.layout(ViewGroup.java:6174)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2761)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2288)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1441)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7076)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:935)
        at android.view.Choreographer.doCallbacks(Choreographer.java:747)
        at android.view.Choreographer.doFrame(Choreographer.java:682)
2018-05-02 01:32:23.588 14475-14475/? E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:921)
        at android.os.Handler.handleCallback(Handler.java:819)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:823)

dependency graph:

debug
debugCompileClasspath - Dependencies for compilation
+--- com.android.databinding:adapters:3.2.0-alpha12@aar
+--- com.android.databinding:library:3.2.0-alpha12@aar
+--- com.android.databinding:baseLibrary:3.2.0-alpha12@jar
+--- com.squareup.leakcanary:leakcanary-android:1.5.4@aar
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.2.41@jar
+--- com.squareup.moshi:moshi-kotlin:1.5.0@jar
+--- org.jetbrains.kotlin:kotlin-reflect:1.2.41@jar
+--- androidx.core:core-ktx:0.3@aar
+--- com.android.support.constraint:constraint-layout:1.1.0@aar
+--- com.android.support:cardview-v7:27.1.1@aar
+--- com.google.dagger:dagger-android-support:2.15@aar
+--- com.jakewharton.rxbinding2:rxbinding-appcompat-v7-kotlin:2.1.1@aar
+--- com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.1.1@aar
+--- com.jakewharton.rxbinding2:rxbinding-design-kotlin:2.1.1@aar
+--- com.jakewharton.rxbinding2:rxbinding-design:2.1.1@aar
+--- com.android.support:design:27.1.1@aar
+--- com.android.support:appcompat-v7:27.1.1@aar
+--- com.android.support:gridlayout-v7:27.1.1@aar
+--- com.android.support:support-v13:27.1.1@aar
+--- com.android.support:support-v4:27.1.1@aar
+--- com.android.support:animated-vector-drawable:27.1.1@aar
+--- com.github.bumptech.glide:glide:4.7.1@aar
+--- com.android.support:support-fragment:27.1.1@aar
+--- com.android.support:recyclerview-v7:27.1.1@aar
+--- com.android.support:support-core-ui:27.1.1@aar
+--- com.android.support:support-core-utils:27.1.1@aar
+--- com.jakewharton.timber:timber:4.7.0@aar
+--- com.jakewharton.rxbinding2:rxbinding-kotlin:2.1.1@aar
+--- com.jakewharton.rxbinding2:rxbinding:2.1.1@aar
+--- io.reactivex.rxjava2:rxandroid:2.0.2@aar
+--- com.squareup.retrofit2:adapter-rxjava2:2.4.0@jar
+--- io.reactivex.rxjava2:rxjava:2.1.13@jar
+--- com.google.dagger:dagger-android:2.15@aar
+--- com.google.dagger:dagger:2.15@jar
+--- com.squareup.okhttp3:logging-interceptor:3.10.0@jar
+--- com.squareup.retrofit2:converter-moshi:2.4.0@jar
+--- com.squareup.retrofit2:retrofit:2.4.0@jar
+--- com.squareup.okhttp3:okhttp:3.10.0@jar
+--- com.android.support:support-media-compat:27.1.1@aar
+--- com.android.support:support-vector-drawable:27.1.1@aar
+--- com.android.support:transition:27.1.1@aar
+--- com.android.support:support-compat:27.1.1@aar
+--- android.arch.lifecycle:runtime:1.1.0@aar
+--- com.squareup.leakcanary:leakcanary-analyzer:1.5.4@aar
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.41@jar
+--- org.jetbrains.kotlin:kotlin-stdlib:1.2.41@jar
+--- com.github.bumptech.glide:gifdecoder:4.7.1@aar
+--- android.arch.lifecycle:livedata-core:1.1.0@aar
+--- android.arch.lifecycle:common:1.1.0@jar
+--- android.arch.core:runtime:1.1.0@aar
+--- android.arch.core:common:1.1.0@jar
+--- com.android.support:support-annotations:27.1.1@jar
+--- com.android.support.constraint:constraint-layout-solver:1.1.0@jar
+--- com.github.bumptech.glide:disklrucache:4.7.1@jar
+--- com.github.bumptech.glide:annotations:4.7.1@jar
+--- javax.inject:javax.inject:1@jar
+--- com.squareup.moshi:moshi:1.5.0@jar
+--- com.squareup.okio:okio:1.14.0@jar
+--- com.squareup.leakcanary:leakcanary-watcher:1.5.4@jar
+--- com.squareup.haha:haha:2.0.3@jar
+--- org.jetbrains:annotations:13.0@jar
+--- org.reactivestreams:reactive-streams:1.0.2@jar
\--- android.arch.lifecycle:viewmodel:1.1.0@aar

layout.xml is a view holder for a recyclerview

<?xml version="1.0" encoding="utf-8"?>

<layout 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">

    <data>

        <variable
            name="listing"
            type="com.example.derek.trademeapi.model.Listing" />
    </data>

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        app:cardCornerRadius="4dp">

        <android.support.constraint.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/item_image_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minWidth="90dp"
                android:minHeight="90dp"
                android:scaleType="fitXY"
                app:imageUrl="@{listing.pictureHref}"
                app:layout_constraintBottom_toTopOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintRight_toRightOf="parent" />

            <android.support.constraint.Guideline
                android:id="@+id/item_text_guide_line"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                app:layout_constraintBottom_toTopOf="@id/item_id_text_view"
                app:layout_constraintLeft_toLeftOf="@id/item_image_view"
                app:layout_constraintRight_toRightOf="@id/item_image_view"
                />

            <TextView
                android:id="@+id/item_id_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:minWidth="40dp"
                android:text="@{Integer.toString(listing.listingId)}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/item_text_guide_line" />

            <TextView
                android:id="@+id/item_title_text_view"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@{listing.title}"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintRight_toRightOf="@id/item_id_text_view"
                app:layout_constraintTop_toBottomOf="@+id/item_text_guide_line" />

        </android.support.constraint.ConstraintLayout>

        <TextView
            android:id="@+id/info_text"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v7.widget.CardView>

</layout>

hereisderek added a commit to hereisderek/trademeapidemo that referenced this issue May 1, 2018

listing screen (recycler view, data binding)
save up before ditching ConstraintLayout (android.support.constraint.Guideline is crashing)
googlecodelabs/constraint-layout#51
@wajahatkarim3

This comment has been minimized.

Copy link

commented Mar 21, 2019

I recently had this problem and solved it. The problem is that we cannot constraint other views vertically to a vertical guideline. For example, we cannot set any TextView to top and bottom to the vertical guidelines's top and bottom. And same goes for the horizontal guidelines as well. I published a detailed article about it as well on Medium at https://android.jlelse.eu/fixing-constraintlayout-guideline-assertionerror-exception-in-android-5dce450b76fb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.