title: App crash caused by data binding related to java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable
body: <p>The exception is the following:</p>
  
  <pre><code>java.lang.NullPointerException: Attempt to read from field 'java.lang.Runnable android.databinding.ViewDataBinding.mRebindRunnable' on a null object reference
          at android.databinding.ViewDataBinding.access$100(ViewDataBinding.java:51)
          at android.databinding.ViewDataBinding$5.onViewAttachedToWindow(ViewDataBinding.java:142)
          at android.view.View.dispatchAttachedToWindow(View.java:14525)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2836)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2843)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1364)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
          at android.view.Choreographer.doCallbacks(Choreographer.java:670)
          at android.view.Choreographer.doFrame(Choreographer.java:606)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:148)
          at android.app.ActivityThread.main(ActivityThread.java:5417)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
  </code></pre>
  
  <p>Let me try my best to make the description brief and clear.</p>
  
  <p>First, this is related to a layout added dynamically.  The activity's data binding works perfectly without any problem.
  Here is the layout foo_view:</p>
  
  <pre><code>&lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"&gt;
      &lt;data&gt;
          &lt;variable
              name="foo"
              type="net.mydomain.myapp.MyActivity.Foo" /&gt;
          &lt;import type="android.view.View" /&gt;
      &lt;/data&gt;
      &lt;!--For the sake of debugging, no data binding is actually used--&gt;
      ...
  &lt;/layout&gt;
  </code></pre>
  
  <p>In MyActivity.java:</p>
  
  <pre><code>public class MyActivity extends AppCompatActivity {
      public class Foo{
         ...
      }
  
  
     ...
     addFoo(){
         FooViewBinding binding = DataBindingUtil.inflate(LayoutInflater.from(this), R.layout.foo_view, myGridLayout, true); 
         Foo foo = new Foo();
         binding.setFoo(foo);  
     }
  }
  </code></pre>
  
  <p>The app cashes immediately upon the start of MyActivity. The crash is not caused by a specific line of code.</p>
  
  <p>Could anyone shed some light on this?</p>
  
  <p><strong>[Edit] 2016-06-30</strong></p>
  
  <p>The crash happens on a Lollipop, but same code works fine on a Jelly Bean</p>