androidnavigation-drawerforceclosedrawer

Why this Drawer Force Closes my app?


I haven't changed this part of my app, but after I rebuilt it, this force close displaying:

java.lang.IllegalStateException: Child drawer has absolute gravity LEFT but this DrawerLayout already has a drawer view along that edge   Exception.

My Activity Layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/draw"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/lin_hime_body"
    android:orientation="vertical">
    <include
        layout="@layout/lay_title_main"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/frm_home"/>
</LinearLayout>
<LinearLayout
    android:layout_width="80dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:orientation="vertical"
    android:id="@+id/menu1">
    <include layout="@layout/lay_menu1"/>
</LinearLayout>
<LinearLayout
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:orientation="vertical"
    android:id="@+id/menu2">
    <include layout="@layout/lay_menu2"/>
</LinearLayout>
<LinearLayout
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="end"
    android:orientation="vertical"
    android:id="@+id/menu3">
    <include layout="@layout/lay_menu3"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>

I got this exception

java.lang.IllegalStateException: Child drawer has absolute gravity
LEFT but this DrawerLayout already has a drawer view along that edge
                                                                            at
android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1089)
                                                                            at android.view.View.measure(View.java:18916)
                                                                            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5972)
                                                                            at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                            at android.view.View.measure(View.java:18916)
                                                                            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5972)
                                                                            at
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1465)
                                                                            at android.widget.LinearLayout.measureVertical(LinearLayout.java:748)
                                                                            at android.widget.LinearLayout.onMeasure(LinearLayout.java:630)
                                                                            at android.view.View.measure(View.java:18916)
                                                                            at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5972)
                                                                            at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
                                                                            at
com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2693)
                                                                            at android.view.View.measure(View.java:18916)
                                                                            at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2218)
                                                                            at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1294)
                                                                            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1536)
                                                                            at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1185)
                                                                            at
android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6255)
                                                                            at
android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)
                                                                            at android.view.Choreographer.doCallbacks(Choreographer.java:676)
                                                                            at android.view.Choreographer.doFrame(Choreographer.java:606)
                                                                            at
android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)
                                                                            at android.os.Handler.handleCallback(Handler.java:739)
                                                                            at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                            at android.os.Looper.loop(Looper.java:168)
                                                                            at android.app.ActivityThread.main(ActivityThread.java:5885)
                                                                            at java.lang.reflect.Method.invoke(Native Method)
                                                                            at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:819)
                                                                            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:709)

Solution

  • Try This if it works:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/draw"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
            <LinearLayout
                android:id="@+id/lin_hime_body"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
    
                <include
                    layout="@layout/lay_title_main"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content" />
    
                <FrameLayout
                    android:id="@+id/frm_home"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
            </LinearLayout>
    
            <LinearLayout
                android:id="@+id/menu1"
                android:layout_width="80dp"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:orientation="vertical">
    
                <include layout="@layout/lay_menu1" />
            </LinearLayout>
    
            <LinearLayout
                android:id="@+id/menu2"
                android:layout_width="240dp"
                android:layout_height="match_parent"
                android:layout_gravity="start"
                android:orientation="vertical">
    
                <include layout="@layout/lay_menu2" />
            </LinearLayout>
        </RelativeLayout>
    
        <LinearLayout
            android:id="@+id/menu3"
            android:layout_width="240dp"
            android:layout_height="match_parent"
            android:layout_gravity="left"
            android:orientation="vertical">
    
            <include layout="@layout/lay_menu3" />
        </LinearLayout>
    
    
    </android.support.v4.widget.DrawerLayout>