title: Fatal exception:main Android Eclipse
body: <p>I am new on android and trying to develop simple calculator but this Fatal exception : main occurs please help.</p>
  
  <p>I did comment my onClickListner to check but it did'nt helped at all.</p>
  
  <pre><code>package com.example.calculatorsinglescreen;
  
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class MainActivity extends ActionBarActivity {
  
  EditText value1,value2,myoperator,result;
  Button ok;
  String strvalue1,strvalue2,stroperator,strresult;
  int ivalue1,ivalue2,ioperator,iresult;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      value1 = (EditText) findViewById(R.id.txtvalue1);
      value2 = (EditText) findViewById(R.id.txtvalue2);
      myoperator = (EditText) findViewById(R.id.txtoperator);
      result = (EditText) findViewById(R.id.txtresult);
      ok = (Button) findViewById(R.id.btnok);
  
      strvalue1 = value1.getText().toString();
      strvalue2 = value2.getText().toString();
      stroperator = myoperator.getText().toString();
  
      ivalue1 = Integer.parseInt(strvalue1);
      ivalue2 = Integer.parseInt(strvalue2);
  
  
  
  
  
      ok.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
  
              if (stroperator.equals("+")) {
  
                  Toast msg = Toast.makeText(MainActivity.this, "If is running", Toast.LENGTH_LONG);
                  msg.show();
  
                  }
  
          }
      });
  }
  
  
  
  @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>}</p>
  
  <p>This is my XML file :</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.calculatorsinglescreen.MainActivity" &gt;
  
  &lt;TextView
      android:id="@+id/value1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_margin="20dp"
      android:text="Value 1" /&gt;
  
  &lt;TextView
      android:id="@+id/value2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/value1"
      android:layout_margin="20dp"
      android:text="Value 2" /&gt;
  
  &lt;TextView
      android:id="@+id/operator"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/value2"
      android:layout_margin="20dp"
      android:text="Operator" /&gt;
  
  &lt;EditText
      android:id="@+id/txtvalue1"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_toRightOf="@+id/value1"
      android:layout_alignBaseline="@+id/value1"
      android:layout_alignParentRight="true"
      android:ems="10" &gt;
  
      &lt;requestFocus /&gt;
  &lt;/EditText&gt;
  
  &lt;EditText
      android:id="@+id/txtoperator"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/operator"
      android:layout_below="@+id/txtvalue2"
      android:layout_toRightOf="@+id/operator"
      android:layout_alignParentRight="true"
      android:ems="10" /&gt;
  
  &lt;EditText
      android:id="@+id/txtvalue2"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/value2"
      android:layout_toRightOf="@+id/value2"
      android:layout_below="@+id/txtvalue1"
      android:layout_alignParentRight="true"
      android:ems="10" /&gt;
  
  &lt;Button
      android:id="@+id/btnok"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:text="Ok" /&gt;
  
  &lt;TextView
      android:id="@+id/result"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/btnok"
      android:layout_margin="40dp"
      android:text="Result" /&gt;
  
  &lt;EditText
      android:id="@+id/txtresult"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/result"
      android:layout_toRightOf="@+id/result"
      android:ems="10" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my LogCat to get a clearer view :</p>
  
  <pre><code>10-18 17:51:25.468: D/AndroidRuntime(742): Shutting down VM
  10-18 17:51:25.468: W/dalvikvm(742): threadid=1: thread exiting with uncaught exception (group=0x40015560)
  10-18 17:51:25.488: E/AndroidRuntime(742): FATAL EXCEPTION: main
  10-18 17:51:25.488: E/AndroidRuntime(742): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.calculatorsinglescreen/com.example.calculatorsinglescreen.MainActivity}: java.lang.NumberFormatException: unable to parse '' as integer
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.os.Handler.dispatchMessage(Handler.java:99)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.os.Looper.loop(Looper.java:123)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread.main(ActivityThread.java:3683)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at java.lang.reflect.Method.invokeNative(Native Method)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at java.lang.reflect.Method.invoke(Method.java:507)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at dalvik.system.NativeStart.main(Native Method)
  10-18 17:51:25.488: E/AndroidRuntime(742): Caused by: java.lang.NumberFormatException: unable to parse '' as integer
  10-18 17:51:25.488: E/AndroidRuntime(742):  at java.lang.Integer.parseInt(Integer.java:362)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at java.lang.Integer.parseInt(Integer.java:332)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at com.example.calculatorsinglescreen.MainActivity.onCreate(MainActivity.java:34)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  10-18 17:51:25.488: E/AndroidRuntime(742):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
  10-18 17:51:25.488: E/AndroidRuntime(742):  ... 11 more
  </code></pre>