title: java.lang.NullPointerException: Attempt to invoke virtual method on a null object reference in oncreate method
body: <p>I'm trying to use a sample code on github (<a href="https://github.com/kmshack/Android-ParallaxHeaderViewPager" rel="nofollow">https://github.com/kmshack/Android-ParallaxHeaderViewPager</a>) I exactly copied the codes as they were and just changed their values, but the problem is when I run the app it gives me this error:</p>
  
  <pre><code>07-04 15:42:38.683    6621-6621/com.moradisani.sorush.flstudio E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: com.moradisani.sorush.flstudio, PID: 6621
  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.moradisani.sorush.flstudio/com.moradisani.sorush.flstudio.Edu}: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.moradisani.sorush.flstudio.KenBurnsSupportView.setResourceIds(int[])' on a null object reference
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2411)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2474)
          at android.app.ActivityThread.access$800(ActivityThread.java:144)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:155)
          at android.app.ActivityThread.main(ActivityThread.java:5696)
          at java.lang.reflect.Method.invoke(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:372)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
   Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void com.moradisani.sorush.flstudio.KenBurnsSupportView.setResourceIds(int[])' on a null object reference
          at com.moradisani.sorush.flstudio.Edu.onCreate(Edu.java:58)
          at android.app.Activity.performCreate(Activity.java:5958)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1129)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
  </code></pre>
  
  <p>Here is the lines that are giving error:</p>
  
  <pre><code>package com.moradisani.sorush.flstudio;
  
  import android.annotation.TargetApi;
  import android.graphics.RectF;
  import android.os.Build;
  import android.os.Bundle;
  import android.support.v4.app.Fragment;
  import android.support.v4.app.FragmentManager;
  import android.support.v4.app.FragmentPagerAdapter;
  import android.support.v4.util.SparseArrayCompat;
  import android.support.v4.view.ViewPager;
  import android.support.v7.app.ActionBarActivity;
  import android.text.Spannable;
  import android.text.SpannableString;
  import android.util.TypedValue;
  import android.view.View;
  import android.view.animation.AccelerateDecelerateInterpolator;
  import android.widget.AbsListView;
  import android.widget.ImageView;
  
  import com.nineoldandroids.view.ViewHelper;
  
  public class Edu extends ActionBarActivity implements ScrollTabHolder,      ViewPager.OnPageChangeListener {
  
  private static AccelerateDecelerateInterpolator sSmoothInterpolator = new AccelerateDecelerateInterpolator();
  
  private KenBurnsSupportView mHeaderPicture;
  private View mHeader;
  
  private PagerSlidingTabStrip mPagerSlidingTabStrip;
  private ViewPager mViewPager;
  private PagerAdapter mPagerAdapter;
  
  private int mActionBarHeight;
  private int mMinHeaderHeight;
  private int mHeaderHeight;
  private int mMinHeaderTranslation;
  private ImageView mHeaderLogo;
  
  private RectF mRect1 = new RectF();
  private RectF mRect2 = new RectF();
  
  private TypedValue mTypedValue = new TypedValue();
  private SpannableString mSpannableString;
  private AlphaForegroundColorSpan mAlphaForegroundColorSpan;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      mMinHeaderHeight = getResources().getDimensionPixelSize(R.dimen.min_header_height);
      mHeaderHeight = getResources().getDimensionPixelSize(R.dimen.header_height);
      mMinHeaderTranslation = -mMinHeaderHeight + getActionBarHeight();
  
      setContentView(R.layout.edu);
  
      mHeaderPicture = (KenBurnsSupportView) findViewById(R.id.header_picture);
      mHeaderPicture.setResourceIds(R.drawable.head1, R.drawable.head2);
      mHeaderLogo = (ImageView) findViewById(R.id.header_logo);
      mHeader = findViewById(R.id.header);
  
      mPagerSlidingTabStrip = (PagerSlidingTabStrip) findViewById(R.id.tabs);
      mViewPager = (ViewPager) findViewById(R.id.pager);
      mViewPager.setOffscreenPageLimit(4);
  
      mPagerAdapter = new PagerAdapter(getSupportFragmentManager());
      mPagerAdapter.setTabHolderScrollingContent(this);
  
      mViewPager.setAdapter(mPagerAdapter);
  
      mPagerSlidingTabStrip.setViewPager(mViewPager);
      mPagerSlidingTabStrip.setOnPageChangeListener(this);
      mSpannableString = new SpannableString(getString(R.string.actionbar_title));
      mAlphaForegroundColorSpan = new AlphaForegroundColorSpan(0xffffffff);
  
      ViewHelper.setAlpha(getActionBarIconView(), 0f);
  
      getSupportActionBar().setBackgroundDrawable(null);
  }
  
  @Override
  public void onPageScrollStateChanged(int arg0) {
      // nothing
  }
  
  @Override
  public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
      // nothing
  }
  
  @Override
  public void onPageSelected(int position) {
      SparseArrayCompat&lt;ScrollTabHolder&gt; scrollTabHolders = mPagerAdapter.getScrollTabHolders();
      ScrollTabHolder currentHolder = scrollTabHolders.valueAt(position);
  
      currentHolder.adjustScroll((int) (mHeader.getHeight() + ViewHelper.getTranslationY(mHeader)));
  }
  
  @Override
  public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount, int pagePosition) {
      if (mViewPager.getCurrentItem() == pagePosition) {
          int scrollY = getScrollY(view);
          ViewHelper.setTranslationY(mHeader, Math.max(-scrollY, mMinHeaderTranslation));
          float ratio = clamp(ViewHelper.getTranslationY(mHeader) / mMinHeaderTranslation, 0.0f, 1.0f);
          interpolate(mHeaderLogo, getActionBarIconView(), sSmoothInterpolator.getInterpolation(ratio));
          setTitleAlpha(clamp(5.0F * ratio - 4.0F, 0.0F, 1.0F));
      }
  }
  
  @Override
  public void adjustScroll(int scrollHeight) {
      // nothing
  }
  
  public int getScrollY(AbsListView view) {
      View c = view.getChildAt(0);
      if (c == null) {
          return 0;
      }
  
      int firstVisiblePosition = view.getFirstVisiblePosition();
      int top = c.getTop();
  
      int headerHeight = 0;
      if (firstVisiblePosition &gt;= 1) {
          headerHeight = mHeaderHeight;
      }
  
      return -top + firstVisiblePosition * c.getHeight() + headerHeight;
  }
  
  public static float clamp(float value, float max, float min) {
      return Math.max(Math.min(value, min), max);
  }
  
  private void interpolate(View view1, View view2, float interpolation) {
      getOnScreenRect(mRect1, view1);
      getOnScreenRect(mRect2, view2);
  
      float scaleX = 1.0F + interpolation * (mRect2.width() / mRect1.width() - 1.0F);
      float scaleY = 1.0F + interpolation * (mRect2.height() / mRect1.height() - 1.0F);
      float translationX = 0.5F * (interpolation * (mRect2.left + mRect2.right - mRect1.left - mRect1.right));
      float translationY = 0.5F * (interpolation * (mRect2.top + mRect2.bottom - mRect1.top - mRect1.bottom));
  
      ViewHelper.setTranslationX(view1, translationX);
      ViewHelper.setTranslationY(view1, translationY - ViewHelper.getTranslationY(mHeader));
      ViewHelper.setScaleX(view1, scaleX);
      ViewHelper.setScaleY(view1, scaleY);
  }
  
  private RectF getOnScreenRect(RectF rect, View view) {
      rect.set(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
      return rect;
  }
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public int getActionBarHeight() {
      if (mActionBarHeight != 0) {
          return mActionBarHeight;
      }
  
      if(Build.VERSION.SDK_INT &gt; Build.VERSION_CODES.HONEYCOMB){
          getTheme().resolveAttribute(android.R.attr.actionBarSize, mTypedValue, true);
      }else{
          getTheme().resolveAttribute(R.attr.actionBarSize, mTypedValue, true);
      }
  
      mActionBarHeight = TypedValue.complexToDimensionPixelSize(mTypedValue.data, getResources().getDisplayMetrics());
  
      return mActionBarHeight;
  }
  
  private void setTitleAlpha(float alpha) {
      mAlphaForegroundColorSpan.setAlpha(alpha);
      mSpannableString.setSpan(mAlphaForegroundColorSpan, 0, mSpannableString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
      getSupportActionBar().setTitle(mSpannableString);
  }
  
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  private ImageView getActionBarIconView() {
  
      if(Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB){
          return (ImageView)findViewById(android.R.id.home);
      }
  
      return (ImageView)findViewById(android.support.v7.appcompat.R.id.home);
  }
  
  public class PagerAdapter extends FragmentPagerAdapter {
  
      private SparseArrayCompat&lt;ScrollTabHolder&gt; mScrollTabHolders;
      private final String[] TITLES = { "Page 1", "Page 2", "Page 3", "Page 4"};
      private ScrollTabHolder mListener;
  
      public PagerAdapter(FragmentManager fm) {
          super(fm);
          mScrollTabHolders = new SparseArrayCompat&lt;ScrollTabHolder&gt;();
      }
  
      public void setTabHolderScrollingContent(ScrollTabHolder listener) {
          mListener = listener;
      }
  
      @Override
      public CharSequence getPageTitle(int position) {
          return TITLES[position];
      }
  
      @Override
      public int getCount() {
          return TITLES.length;
      }
  
      @Override
      public Fragment getItem(int position) {
          ScrollTabHolderFragment fragment = (ScrollTabHolderFragment) ListFragment.newInstance(position);
  
          mScrollTabHolders.put(position, fragment);
          if (mListener != null) {
              fragment.setScrollTabHolder(mListener);
          }
  
          return fragment;
      }
  
      public SparseArrayCompat&lt;ScrollTabHolder&gt; getScrollTabHolders() {
          return mScrollTabHolders;
      }
  
  }
  }
  </code></pre>