itsmetheperson
itsmetheperson

Reputation: 77

Exception raised during rendering: Circular dependencies cannot exist

Was editing the GUI from activity_main.xml in Android Studio and suddenly I got the formentioned error. I'm not familiar with XML at all(I'm just the designer of the app), any help would be appreciated to get this up and running again so I can continue on with the design.

<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/textView" />

<SeekBar
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/seekBar"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true"
    android:layout_marginBottom="162dp" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_toEndOf="@+id/seekBar"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true"
    android:background="@drawable/imagebutton1"
    android:layout_marginBottom="243dp"
    android:layout_above="@+id/seekBar"
    android:layout_toStartOf="@+id/textView2" />

<ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton2"
    android:background="@drawable/imagebutton2"
    android:layout_toEndOf="@+id/textView2"
    android:layout_gravity="center|left"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="68dp"
    android:layout_alignBottom="@+id/textView3" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Partly Cloudy"
    android:id="@+id/textView3"
    android:textColor="#D1DBBD"
    android:textSize="20dp"
    android:textAlignment="center"
    android:layout_alignEnd="@+id/textView2"
    android:layout_alignBottom="@+id/imageButton2" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="22 ºC"
    android:id="@+id/textView2"
    android:textSize="40dp"
    android:textColor="#D1DBBD"
    android:textAlignment="center"
    android:textIsSelectable="true"
    android:layout_alignBaseline="@+id/textView3"
    android:layout_alignBottom="@+id/textView3"
    android:layout_alignStart="@+id/textView3" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageView2"
    android:background="@drawable/line"
    android:layout_marginBottom="60dp"
    android:layout_alignParentBottom="true"
    android:layout_alignParentStart="true" />

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:text="Bradford"
    android:id="@+id/textView4"
    android:layout_toStartOf="@+id/imageButton2"
    android:textAlignment="center"
    android:layout_alignParentBottom="true"
    android:layout_alignParentEnd="true"
    android:layout_alignStart="@+id/textView2"
    android:textSize="20dp"
    android:textColor="#193441" />

Upvotes: 0

Views: 661

Answers (1)

MadEqua
MadEqua

Reputation: 1142

A circular dependency is when a resource A depends on a resource B, but resource B also depends on A. Something like A -> B -> A, making a 'circle'.

In your case the resources are Views, and I can see at least one circular dependency: your textView2 depends on textView3 (android:layout_alignBaseline="@+id/textView3") which by itself depends on textView2 (android:layout_alignEnd="@+id/textView2"). When this happens it's not possible for the system to properly align them.

Try to arrange your layout in another way to avoid this case. Use LinearLayout and RelativeLayoutto group several views if that makes it easier.

Upvotes: 1

Related Questions