My app crashes when I press any of the two buttons I have added, i.e. bAdd and bSubtract. This is like the second app I have written by following a few tutorials, so this is completely new to me. "xxx" and "yyy" are called when the bSubtract and bAdd buttons are pressed, which then causes the app to crash on my phone. xml, code and logcat shown below.

xml file:

```
<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.myapp1.CalculateActivity" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:text="@string/hello_world"
        android:textSize="25sp" />

    <Button
        android:id="@+id/bSubtract"
        android:onClick="xxx"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/bAdd"
        android:layout_alignBottom="@+id/bAdd"
        android:layout_marginLeft="28dp"
        android:layout_toRightOf="@+id/bAdd"
        android:text="@string/bSubtract" />

    <Button
        android:id="@+id/bAdd"
        android:onClick="yyy"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/textView1"
        android:layout_marginLeft="52dp"
        android:layout_marginTop="25dp"
        android:text="@string/bAdd" />

</RelativeLayout>

```

Code:

```
public class CalculateActivity extends ActionBarActivity {

    int counter;
    TextView display;
    Button add, sub;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculate);

        if (savedInstanceState == null) {
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.container, new PlaceholderFragment()).commit();
        }

        counter = 0;
        display = (TextView) findViewById(R.id.textView1);

    }

    @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);
    }

    /**
    * A placeholder fragment containing a simple view.
    */

    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() { }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                  Bundle savedInstanceState) {
              View rootView = inflater.inflate(R.layout.fragment_calculate,
                      container, false);
              return rootView;
        }
    }

    public void xxx(View view) {
        // Do something in response to button
        counter--;
        display.setText(""+ counter);

    }

    public void yyy(View view) {
        // Do something in response to button
        counter++;
        display.setText(""+ counter);

    }
}

```

LogCat:

```
04-16 23:07:04.409: D/AndroidRuntime(22562): Shutting down VM
04-16 23:07:04.409: W/dalvikvm(22562): threadid=1: thread exiting with uncaught exception (group=0x418db700)
04-16 23:07:04.414: E/AndroidRuntime(22562): FATAL EXCEPTION: main
04-16 23:07:04.414: E/AndroidRuntime(22562): java.lang.IllegalStateException: Could not execute method of the activity
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.view.View$1.onClick(View.java:3838)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.view.View.performClick(View.java:4475)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.view.View$PerformClick.run(View.java:18786)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.os.Handler.handleCallback(Handler.java:730)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.os.Handler.dispatchMessage(Handler.java:92)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.os.Looper.loop(Looper.java:137)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.app.ActivityThread.main(ActivityThread.java:5419)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at java.lang.reflect.Method.invokeNative(Native Method)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at java.lang.reflect.Method.invoke(Method.java:525)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at dalvik.system.NativeStart.main(Native Method)
04-16 23:07:04.414: E/AndroidRuntime(22562): Caused by: java.lang.reflect.InvocationTargetException
04-16 23:07:04.414: E/AndroidRuntime(22562):    at java.lang.reflect.Method.invokeNative(Native Method)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at java.lang.reflect.Method.invoke(Method.java:525)
04-16 23:07:04.414: E/AndroidRuntime(22562):    at android.view.View$1.onClick(View.java:3833)
04-16 23:07:04.414: E/AndroidRuntime(22562):    ... 11 more
04-16 23:07:04.414: E/AndroidRuntime(22562): Caused by: java.lang.NullPointerException
04-16 23:07:04.414: E/AndroidRuntime(22562):    at com.example.myapp1.CalculateActivity.yyy(CalculateActivity.java:83)
04-16 23:07:04.414: E/AndroidRuntime(22562):    ... 14 more
04-16 23:12:14.494: I/Process(22562): Sending signal. PID: 22562 SIG: 9

```