Android Data Binding crash when using include tag with custom view layout
<p>I'm trying to add some custom view using <code>include</code> tag to my activity layout which using DataBinding. My custom view is using DataBinding as well. But I got crash on application start:</p>

<pre><code>05-02 17:30:03.685 12595-12595/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.novachevskyi.databindingtest, PID: 12595
                                                   java.lang.RuntimeException: Unable to start activity ComponentInfo{com.novachevskyi.databindingtest/com.novachevskyi.databindingtest.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.novachevskyi.databindingtest.databinding.CustomViewBinding.invalidateAll()' on a null object reference
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                       at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       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)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.novachevskyi.databindingtest.databinding.CustomViewBinding.invalidateAll()' on a null object reference
                                                       at com.novachevskyi.databindingtest.databinding.ActivityMainBinding.invalidateAll(ActivityMainBinding.java:41)
                                                       at com.novachevskyi.databindingtest.databinding.ActivityMainBinding.&lt;init&gt;(ActivityMainBinding.java:33)
                                                       at com.novachevskyi.databindingtest.databinding.ActivityMainBinding.bind(ActivityMainBinding.java:105)
                                                       at android.databinding.DataBinderMapper.getDataBinder(DataBinderMapper.java:11)
                                                       at android.databinding.DataBindingUtil.bind(DataBindingUtil.java:185)
                                                       at android.databinding.DataBindingUtil.bindToAddedViews(DataBindingUtil.java:299)
                                                       at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:279)
                                                       at android.databinding.DataBindingUtil.setContentView(DataBindingUtil.java:261)
                                                       at com.novachevskyi.databindingtest.MainActivity.onCreate(MainActivity.java:11)
                                                       at android.app.Activity.performCreate(Activity.java:6251)
                                                       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) 
                                                       at android.app.ActivityThread.-wrap11(ActivityThread.java) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       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>MainActivity:</p>

<pre><code>public class MainActivity extends AppCompatActivity {
  @Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    DataBindingUtil.setContentView(this, R.layout.activity_main);
  }
}
</code></pre>

<p>CustomView:</p>

<pre><code>public class CustomView extends LinearLayout {
  public CustomView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  @Override protected void onFinishInflate() {
    super.onFinishInflate();
    DataBindingUtil.bind(this);
  }
}
</code></pre>

<p>activity_main.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;layout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"&gt;

  &lt;RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin"
      tools:context="com.novachevskyi.databindingtest.MainActivity"&gt;

    &lt;include layout="@layout/custom_view"/&gt;

  &lt;/RelativeLayout&gt;

&lt;/layout&gt;
</code></pre>

<p>custom_view.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;layout
    xmlns:android="http://schemas.android.com/apk/res/android"&gt;

  &lt;com.novachevskyi.databindingtest.CustomView
      android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;

    &lt;TextView
        android:text="Hello World!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/&gt;

  &lt;/com.novachevskyi.databindingtest.CustomView&gt;

&lt;/layout&gt;
</code></pre>

<p>I've also created public repo with sample project:
<a href="https://github.com/novachevskyi/DataBinding-issue" rel="noreferrer">https://github.com/novachevskyi/DataBinding-issue</a></p>

<p>I was using data binding with <code>com.android.tools.build:gradle:1.3.1</code> and now, when I've tried to upgrade build tools version to <code>com.android.tools.build:gradle:2.1.0</code>, I'm facing such issue with all my views that contain <code>include</code> xml tag. Will appreciate for any information about issue described above.</p>