title: Android app unable to start activity componentinfo
body: <p>I'm a new Android programmer and recently, a lot of my projects have been getting this error:</p>
  
  <pre><code>07-31 23:45:19.592: ERROR/AndroidRuntime(716): java.lang.RuntimeException: Unable to start     
  
  activity ComponentInfo{com.amrit.musifind/com.amrit.musifind.Main}: 
  
  java.lang.NullPointerException
  </code></pre>
  
  <p>Can anyone help me solve this problem?</p>
  
  <p>Here's the entire logcat stack trace:</p>
  
  <pre><code>07-31 23:45:18.512: INFO/ActivityManager(63): Starting activity: Intent {     
  act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000   
  cmp=com.amrit.musifind/.Main }
  07-31 23:45:18.682: INFO/ActivityManager(63): Start proc com.amrit.musifind for activity   
  com.amrit.musifind/.Main: pid=716 uid=10025 gids={3003}
  07-31 23:45:18.962: INFO/jdwp(716): received file descriptor 20 from ADB
  07-31 23:45:19.102: DEBUG/ddm-heap(716): Got feature list request
  07-31 23:45:19.572: DEBUG/AndroidRuntime(716): Shutting down VM
  07-31 23:45:19.572: WARN/dalvikvm(716): threadid=3: thread exiting with uncaught   
  exception (group=0x4001aa28)
  07-31 23:45:19.572: ERROR/AndroidRuntime(716): Uncaught handler: thread main exiting due 
  to uncaught exception
  07-31 23:45:19.592: ERROR/AndroidRuntime(716): java.lang.RuntimeException: Unable to    
  start activity ComponentInfo{com.amrit.musifind/com.amrit.musifind.Main}:    
  java.lang.NullPointerException
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at    
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at    
  android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2417)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at    
  android.app.ActivityThread.access$2100(ActivityThread.java:116)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  android.os.Handler.dispatchMessage(Handler.java:99)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at       
  android.os.Looper.loop(Looper.java:123)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  android.app.ActivityThread.main(ActivityThread.java:4203)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at    
  java.lang.reflect.Method.invokeNative(Native Method)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  java.lang.reflect.Method.invoke(Method.java:521)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  dalvik.system.NativeStart.main(Native Method)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716): Caused by: java.lang.NullPointerException
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at   
  com.amrit.musifind.Main.onCreate(Main.java:44)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at 
  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     at     
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2364)
  07-31 23:45:19.592: ERROR/AndroidRuntime(716):     ... 11 more
  07-31 23:45:19.612: INFO/Process(63): Sending signal. PID: 716 SIG: 3
  07-31 23:45:19.612: INFO/dalvikvm(716): threadid=7: reacting to signal 3
  07-31 23:45:19.642: INFO/dalvikvm(716): Wrote stack trace to '/data/anr/traces.txt'
  07-31 23:45:21.422: INFO/Process(716): Sending signal. PID: 716 SIG: 9
  07-31 23:45:21.442: INFO/ActivityManager(63): Process com.amrit.musifind (pid 716) has   
  died.
  07-31 23:45:21.583: WARN/UsageStats(63): Unexpected resume of com.android.launcher while    
  already resumed in com.amrit.musifind
  07-31 23:45:21.712: WARN/InputManagerService(63): Window already focused, ignoring focus    
  gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@439559d0
  07-31 23:45:23.482: DEBUG/AndroidRuntime(725): &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; AndroidRuntime START    
  &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  07-31 23:45:23.482: DEBUG/AndroidRuntime(725): CheckJNI is ON
  07-31 23:45:23.812: DEBUG/AndroidRuntime(725): --- registering native functions ---
  07-31 23:45:23.832: INFO/jdwp(725): received file descriptor 20 from ADB
  07-31 23:45:24.193: DEBUG/ddm-heap(725): Got feature list request
  07-31 23:45:25.052: DEBUG/AndroidRuntime(725): Shutting down VM
  07-31 23:45:25.052: DEBUG/dalvikvm(725): DestroyJavaVM waiting for non-daemon threads to   
  exit
  07-31 23:45:25.062: DEBUG/dalvikvm(725): DestroyJavaVM shutting VM down
  07-31 23:45:25.062: DEBUG/dalvikvm(725): HeapWorker thread shutting down
  07-31 23:45:25.062: DEBUG/dalvikvm(725): HeapWorker thread has shut down
  07-31 23:45:25.073: DEBUG/jdwp(725): JDWP shutting down net...
  07-31 23:45:25.073: DEBUG/jdwp(725): +++ peer disconnected
  07-31 23:45:25.073: INFO/dalvikvm(725): Debugger has detached; object registry had 1   
  entries
  07-31 23:45:25.093: DEBUG/dalvikvm(725): VM cleaning up
  07-31 23:45:25.113: DEBUG/dalvikvm(725): LinearAlloc 0x0 used 665652 of 4194304 (15%)
  07-31 23:47:22.712: DEBUG/dalvikvm(104): GC freed 9173 objects / 524184 bytes in 149ms
  </code></pre>
  
  <p>Heres the 1st activity: start.java</p>
  
  <pre><code>package com.amrit.musifind;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  
  import org.apache.http.HttpResponse;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  
  import com.amrit.musifind.R;
  
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.Toast;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public abstract class start extends Activity implements OnClickListener {
  
  Button buttonGo, buttonReset;
  EditText EditTextinput;
  String input = "";
  String ur = "http://www.tastekid.com/ask/ws?q=";
  String l = "&amp;f=musifin2125&amp;k=mjjlnzkyzwuz&amp;format=JSON";
  String url = "" ;
  
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      buttonGo = (Button) findViewById(R.id.buttonGo);
      buttonReset = (Button) findViewById(R.id.buttonReset);
  
      EditTextinput = (EditText) findViewById(R.id.EditTextinput);
  
      //Button listener
      buttonReset.setOnClickListener(this);
      buttonGo.setOnClickListener(this);
  }
  
  public void onClick (View src){
      switch(src.getId()){
          case R.id.buttonGo:
              input = EditTextinput.getText().toString();
              url = ur + input + l  ;
  
              Intent Main = new Intent(this, ToClass.class);
              Main.putExtra("userurl", url);
              startActivity(Main);
              break;
  
          case R.id.buttonReset:
              EditTextinput.setText("");
              break;
          }
      }
  }
  </code></pre>
  
  <p>The second activity: Main.java</p>
  
  <pre><code>package com.amrit.musifind;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import org.w3c.dom.Document;
  import org.w3c.dom.Element;
  import org.w3c.dom.NodeList;
  
  import com.amrit.musifind.JSONfunctions;
  import com.amrit.musifind.R;
  
  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.Toast;
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  
  public class Main extends ListActivity {
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.listplaceholder);
  
      Intent intent = getIntent();
      String url = intent.getExtras().getString("userurl");
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; mylist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;    
      ();
  
      JSONObject json = JSONfunctions.getJSONfromURL(url);
  
      try{
          JSONObject earthquakes = json.getJSONObject("Similar");
          JSONArray info = earthquakes.getJSONArray("Results");
  
          for (int i = 0; i &lt; info.length(); i++) {
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();
              JSONObject e = info.getJSONObject(i);
  
              map.put("id", String.valueOf(i));
              map.put("name", "Name:" + e.getString("Name"));
              map.put("type", "Type: " + e.getString("Type"));
              mylist.add(map);
          }
  
          JSONArray  results = json.getJSONArray("Results");
  
          for(int i=0;i&lt;results.length();i++){                        
              HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;();    
              JSONObject e = results.getJSONObject(i);
  
              map.put("id",  String.valueOf(i));
              map.put("name", "Name:" + e.getString("name"));
              map.put("type", "Type: " +  e.getString("type"));
              mylist.add(map);            
          }       
      } catch(JSONException e) {
           Log.e("log_tag", "Error parsing data "+e.toString());
      }
  
      ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.main, 
           new String[] { "name", "type" }, 
           new int[] { R.id.item_title, R.id.item_subtitle });
  
      setListAdapter(adapter);
  
      final ListView lv = getListView();
      lv.setTextFilterEnabled(true);  
      lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {              
              @SuppressWarnings("unchecked")
              HashMap&lt;String, String&gt; o = (HashMap&lt;String, String&gt;) lv.getItemAtPosition(position);                   
              Toast.makeText(Main.this, "ID '" + o.get("id") + "' was clicked.", 
                  Toast.LENGTH_SHORT).show(); 
              }
          });
      }
  }
  </code></pre>
  
  <p>Lastly, my manifest file: AndroidManifest.xml</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.amrit.musifind"
      android:versionCode="1"
      android:versionName="1.0"&gt;
      &lt;uses-sdk android:minSdkVersion="4" /&gt;
  
      &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
          &lt;activity android:name=".start" android:label="@string/app_name"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.start" /&gt;
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity android:name= ".Main"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.Main" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Any help is much appreciated, without solving this problem I can't test my app out!</p>