NullPointerExceptionError
<p>This basic app which was given to me as an project should run quite easily is giving me the hardest time.
Well,I commented everything in my activity and still the same error occurs. So I think that the error is somewhere in the xml files. Please help if you can spot the error.And yeah,the main file is pretty big,but please go through it.</p>

<p>Main.xml :</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&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;Gallery 
android:id="@+id/gallery1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="2dp"&gt;

&lt;TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:text="Length" /&gt;
&lt;/RelativeLayout&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dp"&gt;


&lt;Spinner
    android:id="@+id/spinner1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true" /&gt;

&lt;Spinner
    android:id="@+id/spinner2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true" /&gt;

&lt;/RelativeLayout&gt;


&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_marginTop="5dp"&gt;

&lt;TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="FROM" android:textColor="#FFFF00"/&gt;

&lt;EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="15dp"
    android:layout_toRightOf="@+id/textView2"
    android:ems="10"
    android:inputType="numberDecimal" android:clickable="false"  android:focusable="false" android:focusableInTouchMode="false"&gt;

    &lt;requestFocus /&gt;
&lt;/EditText&gt;

&lt;/RelativeLayout&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" &gt;

&lt;TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="TO      " android:textColor="#FFFF00" android:clickable="false"  android:focusable="false" android:focusableInTouchMode="false"/&gt;

&lt;EditText
    android:id="@+id/editText2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="15dp"
    android:layout_toRightOf="@+id/textView3"
    android:ems="10"
    android:inputType="numberDecimal"/&gt;

&lt;/RelativeLayout&gt;


&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center_horizontal"     android:layout_marginTop="5dp"&gt;

&lt;Button
    android:id="@+id/b1"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="1" 
    /&gt;


&lt;Button
    android:id="@+id/b2"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b1"
    android:text="2" /&gt;

 &lt;Button
    android:id="@+id/b3"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"

    android:layout_toRightOf="@+id/b2"
    android:text="3" /&gt;

&lt;/RelativeLayout&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center"&gt;

&lt;Button
    android:id="@+id/b4"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="4" /&gt;

&lt;Button
   android:id="@+id/b5"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b4"

    android:text="5" /&gt;

&lt;Button
    android:id="@+id/b6"
    android:layout_width="70dp"
    android:layout_height="40dp"

    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b5"
    android:text="6"  /&gt;

&lt;/RelativeLayout&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center"&gt;

&lt;Button
    android:id="@+id/b7"

    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="7" /&gt;

&lt;Button
   android:id="@+id/b8"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b7"
    android:text="8" /&gt;

&lt;Button
    android:id="@+id/b9"

    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b8"
    android:text="9" /&gt;

&lt;/RelativeLayout&gt;

&lt;RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:gravity="center"&gt;

&lt;Button

    android:id="@+id/bdot"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:text="." /&gt;

&lt;Button
    android:id="@+id/b0"
    android:layout_width="70dp"

    android:layout_height="40dp"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/bdot"
    android:text="0" /&gt;

&lt;Button
    android:id="@+id/bc"
    android:layout_width="70dp"
    android:layout_height="40dp"
    android:layout_alignParentTop="true"

    android:layout_marginLeft="16dp"
    android:layout_toRightOf="@+id/b0"
    android:text="C" /&gt;

&lt;/RelativeLayout&gt;

&lt;/LinearLayout&gt;
</code></pre>

<p>strings.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
</code></pre>

<p></p>

<pre><code>&lt;string name="hello"&gt;Hello World, GurkhaActivity!&lt;/string&gt;
&lt;string name="app_name"&gt;Gurkha&lt;/string&gt;
&lt;string-array name="length"&gt;
    &lt;item&gt;Metre&lt;/item&gt;
    &lt;item&gt;Centimetre&lt;/item&gt;
    &lt;item&gt;Kilometre&lt;/item&gt;
&lt;/string-array&gt;
    &lt;string-array name="weight"&gt;
    &lt;item&gt;Gram&lt;/item&gt;
    &lt;item&gt;Kilogram&lt;/item&gt;
    &lt;item&gt;Milligram&lt;/item&gt;
&lt;/string-array&gt;

&lt;/resources&gt;
</code></pre>

<p>attrs.xml //For Gallery</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
&lt;declare-styleable name="HelloGallery"&gt;
    &lt;attr name="android:galleryItemBackground" /&gt;
&lt;/declare-styleable&gt;
&lt;/resources&gt;
</code></pre>

<p>manifest.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.sanjay.gurkha"
android:versionCode="1"
android:versionName="1.0" &gt;

&lt;uses-sdk android:minSdkVersion="3" /&gt;

&lt;application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" &gt;
    &lt;activity
        android:name=".GurkhaActivity"
        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;/application&gt;

&lt;/manifest&gt;
</code></pre>

<p>Logcat :</p>

<pre><code>03-24 01:30:03.729: D/AndroidRuntime(631): Shutting down VM
03-24 01:30:03.769: W/dalvikvm(631): threadid=1: thread exiting with uncaught exception (group=0x409c01f8)
03-24 01:30:03.939: E/AndroidRuntime(631): FATAL EXCEPTION: main
03-24 01:30:03.939: E/AndroidRuntime(631): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.sanjay.gurkha/com.sanjay.gurkha.GurkhaActivity}: java.lang.NullPointerException
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.os.Looper.loop(Looper.java:137)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.main(ActivityThread.java:4424)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.reflect.Method.invokeNative(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.reflect.Method.invoke(Method.java:511)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-24 01:30:03.939: E/AndroidRuntime(631):  at dalvik.system.NativeStart.main(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631): Caused by: java.lang.NullPointerException
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.Activity.findViewById(Activity.java:1794)
03-24 01:30:03.939: E/AndroidRuntime(631):  at com.sanjay.gurkha.GurkhaActivity.&lt;init&gt;(GurkhaActivity.java:28)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.Class.newInstanceImpl(Native Method)
03-24 01:30:03.939: E/AndroidRuntime(631):  at java.lang.Class.newInstance(Class.java:1319)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-24 01:30:03.939: E/AndroidRuntime(631):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-24 01:30:03.939: E/AndroidRuntime(631):  ... 11 more
</code></pre>
