DrawerLayout must be measured with MeasureSpec.EXACTLY error

This can also happen because of the new ConstraintLayout. Make sure the drawer layout isn't in the hierarchy of ConstraintLayout.

Edit

Make sure you are using right constraints to ensure that height is not 0dp when using constraint layout


My DrawerLayout was inside a LinearLayout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="@drawable/abohawawallpapersqr"
    tools:context=".MainActivity">

        <include layout="@layout/toolbar" />

        <android.support.v4.widget.DrawerLayout
            android:id="@+id/drawerLayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"> 

        <!-- ...... -->
        </android.support.v4.widget.DrawerLayout>
</LinearLayout>

Then I solved the problem by changing the layout_height="wrap_content" to layout_height="match_parent" of LinearLayout.So the code is:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@drawable/abohawawallpapersqr"
    tools:context=".MainActivity">

For those who still have an exception, ensure your DrawerLayout's height is match_parent