-1

Hi

I got this error in my layout, looks like there is no problems, but this appears when trying to open the layout in Test device:

java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1704)
at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:382)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:390)
at android.view.View.measure(View.java:17951)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1269)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
at android.widget.ScrollView.onMeasure(ScrollView.java:338)
at android.view.View.measure(View.java:17951) .......

Here is my XML: Click here

What causes the "Circular dependencies cannot exist in RelativeLayout"-problem?

Pawan
  • 533
  • 1
  • 7
  • 31

2 Answers2

1

Circular dependencies cannot exist in RelativeLayout

The problem is caused when there is a circular reference in the layout parameters.

For example, you have a button A layout_below to button B, now you can not give any alignment references of button A to button B like button B align_right to button A.

Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
1

Following code in your layout caused the circular dependencies,

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Weight"
            android:id="@+id/weig"
            android:layout_marginEnd="40dp"
            android:layout_above="@+id/weightn"
            android:layout_alignParentEnd="true"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:text="46"
            android:id="@+id/weightn"
            android:layout_below="@+id/weig"
            android:layout_alignEnd="@+id/weig"
            android:layout_marginRight="7dp"
            android:textColor="#ffffff" />

Cause:

First Text View(weig) : android:layout_above="@+id/weightn"

Second Text View(weightn) : android:layout_below="@+id/weig"

Pandiarajan
  • 322
  • 2
  • 9