title: Exception from LayerDrawable
body: <p>I've an android app that using android support library version <code>23.2.1</code> and everything is working fine. However, I've updated the android support library version to <code>25.2.0</code> yesterday and realize some of the user are getting this exception (through Fabric crashlytics) but I couldn't reproduce it.</p>
  
  <p>Here is the crash log:</p>
  
  <pre><code>Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' on a null object reference
     at android.graphics.drawable.LayerDrawable$ChildDrawable.&lt;init&gt;(LayerDrawable.java:959)
     at android.graphics.drawable.LayerDrawable$LayerState.&lt;init&gt;(LayerDrawable.java:1007)
     at android.graphics.drawable.LayerDrawable.createConstantState(LayerDrawable.java:133)
     at android.graphics.drawable.LayerDrawable.&lt;init&gt;(LayerDrawable.java:126)
     at android.graphics.drawable.LayerDrawable$LayerState.newDrawable(LayerDrawable.java:1048)
     at android.content.res.Resources.getCachedDrawableLocked(Resources.java:2777)
     at android.content.res.Resources.getCachedDrawable(Resources.java:2745)
     at android.content.res.Resources.loadDrawable(Resources.java:2586)
     at android.content.res.Resources.getDrawable(Resources.java:900)
     at android.content.Context.getDrawable(Context.java:408)
     at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:30)
     at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:372)
     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:202)
     at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:190)
     at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
     at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:425)
     at android.support.v7.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:129)
     at android.support.v7.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:211)
     at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:186)
     at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:197)
     at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:479)
     at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1160)
     at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:95)
     at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:234)
     at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:292)
     at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1047)
     at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1074)
     at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:460)
     at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)
     at android.os.Handler.handleCallback(Handler.java:815)
     at android.os.Handler.dispatchMessage(Handler.java:104)
     at android.os.Looper.loop(Looper.java:194)
     at android.app.ActivityThread.main(ActivityThread.java:5637)
     at java.lang.reflect.Method.invoke(Method.java)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)
  </code></pre>
  
  <p>It seems to do with menu view. The layout for menu option is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      tools:context=".tablet.ui.navimenu.ContainerActivity"&gt;
  
      &lt;item
          android:id="@+id/memo_fragment"
          android:icon="@drawable/ic_class_white_24dp"
          android:orderInCategory="100"
          android:title="@string/memo_fragment"
          app:showAsAction="always" /&gt;
  
      &lt;item
          android:id="@+id/notification_fragment"
          android:icon="@drawable/layerlist_menu_notification"
          android:orderInCategory="200"
          android:title="@string/notification_fragment"
          app:showAsAction="always" /&gt;
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>layerlist_menu_notification layout is an icon with a badge:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layer-list xmlns:android="http://schemas.android.com/apk/res/android"&gt;
      &lt;item
          android:id="@+id/ic_notification"
          android:drawable="@drawable/ic_notifications_white_24dp"
          android:gravity="center" /&gt;
  
      &lt;!-- set a place holder Drawable so android:drawable isn't null --&gt;
      &lt;item
          android:id="@+id/ic_badge"
          android:drawable="@drawable/ic_notifications_white_24dp" /&gt;
  &lt;/layer-list&gt;
  </code></pre>
  
  <p>Any idea where goes wrong? </p>