title: java.lang.NullPointerException at android.support.v4.view.ViewCompatHC.setAlpha(ViewCompatHC.java:101)
body: <p>I am getting the following error:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myapp/com.example.myapp.MyActivity}:
  java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2350)
              at android.app.ActivityThread.access$800(ActivityThread.java:163)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1257)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:157)
              at android.app.ActivityThread.main(ActivityThread.java:5335)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at android.support.v4.view.ViewCompatHC.setAlpha(ViewCompatHC.java:101)
              at android.support.v4.view.ViewCompat$HCViewCompatImpl.setAlpha(ViewCompat.java:811)
              at android.support.v4.view.ViewCompat.setAlpha(ViewCompat.java:1978)
              at com.example.myapp.MyActivity.onCreate(MyActivity.java:93)
              at android.app.Activity.performCreate(Activity.java:5389)
              at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2256)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2350)
              at android.app.ActivityThread.access$800(ActivityThread.java:163)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1257)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:157)
              at android.app.ActivityThread.main(ActivityThread.java:5335)
              at java.lang.reflect.Method.invokeNative(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:515)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Here's my onCreate block where the error is being thrown from:</p>
  
  <pre><code>@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.activity_profile);
  
     mHeaderPicture = (KenSupportView) findViewById(R.id.header_picture);
     mHeaderPicture.setResourceIds(R.drawable.default_bg_1, R.drawable.default_bg_2);
     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);
  
     ViewCompat.setAlpha(getActionBarIconView(), 0f); // error here
  
     getSupportActionBar().setBackgroundDrawable(null);
  }
  </code></pre>
  
  <p>and the method block for <code>getActionBarIconView()</code>:</p>
  
  <pre><code>    @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);
    }
  </code></pre>
  
  <p>build.gradle:</p>
  
  <pre><code> android {
       compileSdkVersion 21
       buildToolsVersion '20.0.0'
  
       defaultConfig {
           applicationId "com.example.myapp"
           minSdkVersion 15
           targetSdkVersion 20
           versionCode 1
           versionName "1.0"
       }
       buildTypes {
           release {
               runProguard false
               proguardFiles getDefaultProguardFile('proguard-android.txt'),
              'proguard-rules.pro'
           }
       }
   }
  </code></pre>
  
  <p>I'm not sure why it is throwing a null pointer exception when R.id.home resolves to integer 16908332 when I log the error. I've also ensured that setContentView comes first.</p>
  
  <p>Could anyone kindly help?</p>