Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:06:00+00:00 2026-06-14T17:06:00+00:00

I get a strange error in my Android project. Sometimes the app crashes with

  • 0

I get a strange error in my Android project. Sometimes the app crashes with this IllegalStateException:

11-23 08:20:51.610: E/AndroidRuntime(16714): FATAL EXCEPTION: main
11-23 08:20:51.610: E/AndroidRuntime(16714): java.lang.IllegalStateException: Circular dependencies cannot exist in RelativeLayout
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.RelativeLayout$DependencyGraph.getSortedViews(RelativeLayout.java:1286)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.RelativeLayout.sortChildren(RelativeLayout.java:294)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:314)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.View.measure(View.java:12775)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4709)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1385)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:670)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.View.measure(View.java:12775)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4709)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.View.measure(View.java:12775)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.LinearLayout.measureVertical(LinearLayout.java:822)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.View.measure(View.java:12775)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4709)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2240)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.View.measure(View.java:12775)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1117)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.os.Looper.loop(Looper.java:137)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at android.app.ActivityThread.main(ActivityThread.java:4514)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at java.lang.reflect.Method.invokeNative(Native Method)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at java.lang.reflect.Method.invoke(Method.java:511)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
11-23 08:20:51.610: E/AndroidRuntime(16714):    at dalvik.system.NativeStart.main(Native Method)

I know that this should be caused by two widgets in a RelativeLayout referencing each other, but here it’s definitely not the case.
I am using a RelativeLayout in this layout file (at the bottom):

<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="450dp" >

    <fragment
        android:id="@+id/identification_navigation_fragment"
        android:name="plt.demonstrator.common.NavigationFragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1" />

    <View
        android:id="@+id/view1"
        android:layout_width="3dp"
        android:layout_height="match_parent"
        android:layout_weight="0"
        android:background="@color/lightgray" />

    <fragment
        android:id="@+id/identification_fragment"
        android:name="plt.demonstrator.identifikation.IdentificationFragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="3.5" />

</LinearLayout>

<RelativeLayout
    android:id="@+id/bottom_actionbar"
    android:layout_width="match_parent"
    android:layout_height="48dp"
    android:layout_gravity="center_vertical"
    android:background="#DDDDDD" >

</RelativeLayout>

Items are added dynamically at runtime, either on left or right side. So actually no item from left side is referencing something on the right side and vice-versa.
Also I cannot identify any part of my code causing this exception, the debugger runs until onResume() has finished and the app is in resumed state. Here is the code which adds the items, but as I said, the debugger doesn’t argue with this…

public static void addActionbarItem(RelativeLayout actionbar, Context ctx, int itemid, int textid, 
        int iconid, Direction direction, View.OnClickListener listener) {
    TextView item = new TextView(ctx);
    item.setText(ctx.getString(textid).toUpperCase());
    item.setTextAppearance(ctx, android.R.style.TextAppearance_Medium);
    int paddingPx = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 12, ctx.getResources().getDisplayMetrics());
    item.setPadding(paddingPx, 0, paddingPx, 0);
    item.setGravity(Gravity.CENTER_VERTICAL);
    item.setId(itemid);

    Drawable icon = ctx.getResources().getDrawable(iconid);
    icon.setBounds(0, 0, 24, 24);
    item.setCompoundDrawables(icon, null, null, null);

    RelativeLayout.LayoutParams separatorParams = new LayoutParams(1, 32);

    // vertical separator
    View separator = new View(ctx);
    int color = ctx.getResources().getColor(android.R.color.secondary_text_light);
    separator.setBackgroundColor(color);
    separator.setId(separatorId++);
    separatorParams.setMargins(0, 8, 0, 0);

    RelativeLayout.LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);

    if (direction == Direction.LEFT) {
        // Item should be added at left side
        if (leftAnchor != -1) {
            // There is already an item at left side -> place the new item right to it
            separatorParams.addRule(RelativeLayout.RIGHT_OF, leftAnchor);
            separator.setLayoutParams(separatorParams);
            actionbar.addView(separator);
            params.addRule(RelativeLayout.RIGHT_OF, separator.getId());
        } else {
            // Item is the first on left side, place it at left edge
            params.addRule(RelativeLayout.ALIGN_PARENT_LEFT, -1);
            // Add some space to the display edge
            params.setMargins(8, 0, 0, 0);
        }
        // Update anchor ID
        leftAnchor = itemid;
    } else {
        // Item should be added at right side
        if (rightAnchor != -1) {
            // There is already an item at right side -> place the new item left to it
            separatorParams.addRule(RelativeLayout.LEFT_OF, rightAnchor);
            separator.setLayoutParams(separatorParams);
            actionbar.addView(separator);
            params.addRule(RelativeLayout.LEFT_OF, rightAnchor);
        } else {
            // Item is the first on right side, place it at right edge
            params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, -1);
            // Add some space to the display edge
            params.setMargins(0, 0, 8, 0);
        }
        // Update anchor ID
        rightAnchor = itemid;
    }

    item.setLayoutParams(params);
    // Set item behaviour
    item.setOnClickListener(listener);
    // Add a touch listener for visual feedback
    // Touch listener is invoked before click listener, so event must be forwarded after onTouch method
    item.setOnTouchListener(new View.OnTouchListener() {

        public boolean onTouch(final View v, MotionEvent e) {
            // ICS clicked button style
            v.setBackgroundColor(0x880099CC);
            v.invalidate();
            Runnable timer = new Runnable() {
                public void run() {
                    // Reset color
                    v.setBackgroundColor(Color.TRANSPARENT);
                    v.invalidate();
                }
            };
            Handler h = new Handler();
            h.removeCallbacks(timer);
            // Reset button style after 50ms
            h.postDelayed(timer, 50);
            // Forward event to OnClickListener
            return false;
        }
    });

    actionbar.addView(item);
}

Has anybody already faced something like this? Any help is greatly appreciated…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:06:01+00:00Added an answer on June 14, 2026 at 5:06 pm

    Print out your ids in the logcat, for all the views you add dynamically, you will sure find a view that defines a circular dependency in your layout. Your code is not easy to follow but your error is there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created a Hello world app but get this strange error: The project cannot
Sometimes I get this strange error during gameplay: TypeError: Error #1009: Cannot access a
I get a strange error and couldn't find the answer.. This code works well:
Using Entity Framework, I suddenly get this strange error after publishing my asp.net mvc
When using this class I get this strange exception. It is used to print
Grails 1.3.7 I get this strange error when I try to invoke my named
I'm using Python Requests. All works great but today I get this strange error:
In Android 4.1 a, to me, seemingly strange error occurs in our app. In
I get this strange error child pid 1789 exit signal Bus error (10) I
I get a strange PHP error after updating my php version to 5.4.0-3. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.