title: Unable to instantiate activity ComponentInfo .. java.lang.NullPointerException
body: <p>I'm trying to run a simple app using volley and a custom header, it builds with no error, I'm running it directly in my smartphone, but when the app start I get the following log:</p>
  
  <pre><code>06-24 16:35:35.653    1380-1380/com.rep E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: com.rep, PID: 1380
      java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.rep/com.rep.app.principal.InicioActivity}: java.lang.NullPointerException
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2135)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
              at android.app.ActivityThread.access$800(ActivityThread.java:139)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5102)
              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:785)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
              at dalvik.system.NativeStart.main(Native Method)
       Caused by: java.lang.NullPointerException
              at android.content.ContextWrapper.getCacheDir(ContextWrapper.java:230)
              at com.android.volley.toolbox.Volley.newRequestQueue(Volley.java:43)
              at com.android.volley.toolbox.Volley.newRequestQueue(Volley.java:78)
              at com.representemais.app.principal.InicioActivity.&lt;init&gt;(InicioActivity.java:86)
              at java.lang.Class.newInstanceImpl(Native Method)
              at java.lang.Class.newInstance(Class.java:1208)
              at android.app.Instrumentation.newActivity(Instrumentation.java:1084)
              at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2126)
              at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2269)
              at android.app.ActivityThread.access$800(ActivityThread.java:139)
              at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
              at android.os.Handler.dispatchMessage(Handler.java:102)
              at android.os.Looper.loop(Looper.java:136)
              at android.app.ActivityThread.main(ActivityThread.java:5102)
              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:785)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
              at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>that's the InicioActivity:</p>
  
  <pre><code>package com.rep.app.principal;
  
  import android.os.AsyncTask;
  import android.os.Bundle;
  
  import android.util.Log;
  import android.view.View;
  import android.widget.TextView;
  
  import com.actionbarsherlock.app.SherlockFragmentActivity;
  import com.android.volley.AuthFailureError;
  import com.android.volley.Request;
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.VolleyLog;
  import com.android.volley.toolbox.JsonObjectRequest;
  import com.android.volley.toolbox.Volley;
  import com.rep.R;
  
  
  import org.json.JSONObject;
  
  import java.util.HashMap;
  
  import java.util.Map;
  
  
  public class InicioActivity extends SherlockFragmentActivity {
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
  
  
          AutenticacaoLocalTask mAutenticacaoLocalTask = new AutenticacaoLocalTask();
          mAutenticacaoLocalTask.execute((Void) null);
  
      }
      private TextView txtDisplay;
      RequestQueue queue = Volley.newRequestQueue(this);
  
      public class AutenticacaoLocalTask extends AsyncTask&lt;Void, Void, Boolean&gt; {
  
          @Override
          protected Boolean doInBackground(Void... params) {
  
  
              try {
  
  
  
  
                  txtDisplay = (TextView) findViewById(R.id.txtDisplay);
  
                  String url = "http://192.168.1.15/rep-api/api/clients";
  
  
  
  
  
  
  
                   JsonObjectRequest jsonObjReq = new JsonObjectRequest(Request.Method.GET,
                          url, null,
                          new Response.Listener&lt;JSONObject&gt;() {
  
                              @Override
                              public void onResponse(JSONObject response) {
  
                                  txtDisplay.setText("Response =&gt; "+response.toString());
                                  findViewById(R.id.progressBar1).setVisibility(View.GONE);
                              }
                          }, new Response.ErrorListener() {
  
  
  
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          VolleyLog.d("Error: " + error.getMessage());
  
  
                      }
                  })
  
  
  
                  {
  
                      @Override
                      public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
  
                          HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
  
  
                          headers.put("X-API-TOKEN", "99KI9Gj68CgCf70deM22Ka64chef2C40Gm2lFJ2J0G9JkD0bDAcbFfd19MfacGf3FFm8CM1hG0eDiIk8");
  
                          return headers;
                      }
  
  
  
                  };
                  queue.add(jsonObjReq);
  
  
                  return true;
  
              } catch (Exception e) {
                  Log.e("RM", e.getMessage());
                  return false;
              }
  
          }
  
          @Override
          protected void onPostExecute(final Boolean success) {
  
          }
  
          @Override
          protected void onCancelled() {
  
          }
      }
  
  
  }
  </code></pre>
  
  <p>and the Manifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.rep"
      android:versionCode="1"
      android:versionName="1.0"&gt;
  
      &lt;uses-sdk
          android:minSdkVersion="7"
          android:targetSdkVersion="19" /&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"&gt;&lt;/uses-permission&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"&gt;&lt;/uses-permission&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity
              android:name=".app.principal.InicioActivity"
              android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".app.login.LoginActivity"
              android:configChanges="keyboardHidden"
              android:label="@string/app_name"&gt;
          &lt;/activity&gt;
  
          &lt;activity
              android:name=".app.principal.MainActivity"
              android:label="@string/app_name"&gt;&lt;/activity&gt;
  
          &lt;activity android:name=".app.cliente.ClienteDetalheActivity"
              android:label="@string/app_name"&gt;&lt;/activity&gt;
  
          &lt;activity android:name=".app.login.LoginTelaBloqueada"
              android:label="@string/app_name"&gt;&lt;/activity&gt;
      &lt;/application&gt;
  
  
  
  &lt;/manifest&gt;
  </code></pre>