Null pointer Exception on TabLayout : <pre><code>Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.support.design.widget.TabLayout.addOnTabSelectedListener(android.support.design.widget.TabLayout$OnTabSelectedListener)' on a null object reference
</code></pre>

<p>Declared this before onCreate():</p>

<pre><code>TabLayout.OnTabSelectedListener listener;
</code></pre>

<p>and this in onCreate():</p>

<pre><code>TabLayout tabLayout = (TabLayout) findViewById(R.id.tabLayout);
listener = new TabLayout.OnTabSelectedListener(){
        @Override
        public void onTabSelected(TabLayout.Tab tab) {
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(TabLayout.Tab tab) {

        }

        @Override
        public void onTabReselected(TabLayout.Tab tab) {

        }
    };
    tabLayout.addOnTabSelectedListener(listener);
</code></pre>

<p>I'm having trouble seeing how listener is null. I have other NullPointerExceptions that even claim null object on primitives including ints defined by drawable pngs?</p>
