title: Android, threadid=1: thread exiting with uncaught exception (group=0xa4db4b20)
body: <p>I am writing simple code for playing a mp3 on android using android.media.MediaPlayer but I am getting this error  </p>
  
  <blockquote>
    <p>thread exiting with uncaught exception (group=0xa4db4b20) and NPE</p>
  </blockquote>
  
  <p>This is my MainActivity.java :-</p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
  private TextView textView;
  private ImageButton button;
  private MediaPlayer player;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      onGo();
  }
  
  private void onGo() {
  
      button=(ImageButton) findViewById(R.id.imageButton1);
      textView = (TextView) findViewById(R.id.textView1);
      player.create(MainActivity.this, R.raw.kalimba);
  
      button.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View arg0) {
              player.start();     
          }
      });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p>and My Logcat :-</p>
  
  <pre><code>08-31 06:57:27.647: E/OpenGLRenderer(1237): Getting MAX_TEXTURE_SIZE from GradienCache
  08-31 06:57:27.651: E/OpenGLRenderer(1237): MAX_TEXTURE_SIZE: 8192
  08-31 06:57:27.655: E/OpenGLRenderer(1237): Getting MAX_TEXTURE_SIZE from Caches::initConstraints()
  08-31 06:57:27.655: E/OpenGLRenderer(1237): MAX_TEXTURE_SIZE: 8192
  08-31 06:57:27.655: D/OpenGLRenderer(1237): Enabling debug mode 0
  08-31 06:57:29.039: D/AndroidRuntime(1237): Shutting down VM
  08-31 06:57:29.039: W/dalvikvm(1237): threadid=1: thread exiting with uncaught exception (group=0xa4db4b20)
  08-31 06:57:29.051: E/AndroidRuntime(1237): FATAL EXCEPTION: main
  08-31 06:57:29.051: E/AndroidRuntime(1237): Process: com.example.player, PID: 1237
  08-31 06:57:29.051: E/AndroidRuntime(1237): java.lang.NullPointerException
  08-31 06:57:29.051: E/AndroidRuntime(1237): at com.example.player.MainActivity$1.onClick(MainActivity.java:44)
  08-31 06:57:29.051: E/AndroidRuntime(1237):     at android.view.View.performClick(View.java:4438)
  </code></pre>