title: Android unable to start activity componentinfo
body: <p>I'm getting these error on my emulator and app is crashing there. </p>
  
  <p>LogCat</p>
  
  <pre><code>08-30 22:18:20.066: E/AndroidRuntime(860): FATAL EXCEPTION: main
  08-30 22:18:20.066: E/AndroidRuntime(860): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mojoo/com.example.mojoo.main}: java.lang.NullPointerException
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.os.Handler.dispatchMessage(Handler.java:99)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.os.Looper.loop(Looper.java:123)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at java.lang.reflect.Method.invoke(Method.java:507)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at dalvik.system.NativeStart.main(Native Method)
  08-30 22:18:20.066: E/AndroidRuntime(860): Caused by: java.lang.NullPointerException
  08-30 22:18:20.066: E/AndroidRuntime(860):  at com.example.mojoo.main.onCreate(main.java:26)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  08-30 22:18:20.066: E/AndroidRuntime(860):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  08-30 22:18:20.066: E/AndroidRuntime(860):  ... 11 more
  08-30 22:18:21.965: I/Process(860): Sending signal. PID: 860 SIG: 9
  08-30 22:19:08.275: D/AndroidRuntime(894): Shutting down VM
  08-30 22:19:08.275: W/dalvikvm(894): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  08-30 22:19:08.285: E/AndroidRuntime(894): FATAL EXCEPTION: main
  08-30 22:19:08.285: E/AndroidRuntime(894): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mojoo/com.example.mojoo.main}: java.lang.NullPointerException
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.os.Handler.dispatchMessage(Handler.java:99)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.os.Looper.loop(Looper.java:123)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at java.lang.reflect.Method.invokeNative(Native Method)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at java.lang.reflect.Method.invoke(Method.java:507)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at dalvik.system.NativeStart.main(Native Method)
  08-30 22:19:08.285: E/AndroidRuntime(894): Caused by: java.lang.NullPointerException
  08-30 22:19:08.285: E/AndroidRuntime(894):  at com.example.mojoo.main.onCreate(main.java:26)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  08-30 22:19:08.285: E/AndroidRuntime(894):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  08-30 22:19:08.285: E/AndroidRuntime(894):  ... 11 more
  </code></pre>
  
  <p>Here is my src main.java</p>
  
  <pre><code>package com.example.mojoo;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.Bitmap;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.ImageView;
  
  
  public class main extends Activity {
  
      ImageView iv;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          iv=(ImageView) findViewById(R.id.imageView1);
  
          Button b = (Button) findViewById(R.id.button1);
  
          b.setOnClickListener(new OnClickListener() {
  
              public void onClick(View v) {
                  Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
  
                  startActivityForResult(intent, 0);
              }
          });
  
      }
  
      @Override
      protected void onActivityResult(int requestCode, int resultCode, Intent data) {
          super.onActivityResult(requestCode, resultCode, data);
  
          Bitmap bm = (Bitmap) data.getExtras().get("data");
          iv.setImageBitmap(bm);
      }
  
  }
  </code></pre>
  
  <p><strong>EDIT</strong> For some reference of the problem, I'm adding the xml </p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1.03"
          android:orientation="vertical" &gt;
  
          &lt;LinearLayout
              android:layout_width="match_parent"
              android:layout_height="307dp"
              android:orientation="vertical" &gt;
  &lt;LinearLayout
  
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" &gt;
  
                      &lt;LinearLayout
  
                          android:layout_width="172dp"
                          android:layout_height="match_parent"
                          android:orientation="vertical" &gt;
  
                          &lt;RelativeLayout
                              android:layout_width="match_parent"
                              android:layout_height="fill_parent" &gt;
  
                              &lt;TextView
                                  android:id="@+id/textView2"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignParentRight="true"
                                  android:layout_alignParentTop="true"
                                  android:text="MOJO ULTIMATE"
                                  android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
                              &lt;ImageView
                                  android:id="@+id/imageView1"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignLeft="@+id/textView2"
                                  android:layout_alignParentBottom="true"
                                  android:layout_alignParentRight="true"
                                  android:layout_below="@+id/textView2"
                                  android:src="@drawable/mojohdpi" /&gt;
  
                          &lt;/RelativeLayout&gt;
  
                      &lt;/LinearLayout&gt;
  
                      &lt;LinearLayout
  
                          android:layout_width="match_parent"
                          android:layout_height="match_parent"
                          android:orientation="vertical" &gt;
  
                          &lt;RelativeLayout
  
                              android:layout_width="match_parent"
                              android:layout_height="match_parent" &gt;
  
                              &lt;ImageButton
                                  android:id="@+id/imageButton1"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignParentTop="true"
                                  android:layout_centerHorizontal="true"
                                  android:layout_marginTop="14dp"
                                  android:src="@drawable/camerahdpi" /&gt;
  
                              &lt;ImageButton
                                  android:id="@+id/imageButton2"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignRight="@+id/imageButton1"
                                  android:layout_below="@+id/imageButton1"
                                  android:src="@drawable/adohdpi" /&gt;
  
                              &lt;ImageButton
                                  android:id="@+id/imageButton3"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_below="@+id/imageButton2"
                                  android:layout_centerHorizontal="true"
                                  android:src="@drawable/vediohdpi" /&gt;
  
                              &lt;ImageButton
                                  android:id="@+id/imageButton4"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_below="@+id/imageButton3"
                                  android:layout_centerHorizontal="true"
                                  android:src="@drawable/livehdpi" /&gt;
  
                              &lt;ImageButton
                                  android:id="@+id/imageButton5"
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_alignParentBottom="true"
                                  android:layout_alignRight="@+id/imageButton4"
                                  android:layout_below="@+id/imageButton4"
                                  android:src="@drawable/browsehdpi" /&gt;
  
                          &lt;/RelativeLayout&gt;
  
                      &lt;/LinearLayout&gt;
  
                  &lt;/LinearLayout&gt;
  
              &lt;/LinearLayout&gt;
  
  
  
              &lt;LinearLayout
  
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:orientation="vertical" &gt;
  
                  &lt;RelativeLayout
                      android:layout_width="match_parent"
                      android:layout_height="match_parent" &gt;
  
                      &lt;EditText
                          android:id="@+id/editText1"
                          android:layout_width="fill_parent"
                          android:layout_height="wrap_content"
                          android:layout_alignParentTop="true"
                          android:layout_marginTop="18dp"
                          android:ems="10"
                          android:hint="Write an annotation..."
                          android:inputType="textMultiLine" /&gt;
  
                      &lt;RadioButton
                          android:id="@+id/radioButton2"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentBottom="true"
                          android:layout_alignParentRight="true"
                          android:layout_marginRight="114dp" /&gt;
  
                      &lt;RadioButton
                          android:id="@+id/radioButton1"
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_alignParentBottom="true"
                          android:layout_toLeftOf="@+id/radioButton2" /&gt;
  
                      &lt;ImageButton
                          android:id="@+id/imageButton6"
                          android:layout_width="fill_parent"
                          android:layout_height="wrap_content"
                          android:layout_above="@+id/radioButton2"
                          android:layout_alignParentRight="true"
                          android:layout_below="@+id/editText1"
                          android:src="@drawable/okhdpi" /&gt;
  
                  &lt;/RelativeLayout&gt;
  
              &lt;/LinearLayout&gt;
  
          &lt;/LinearLayout&gt;
  
      &lt;/LinearLayout&gt;
  </code></pre>