title: Java: java.lang.IllegalStateException: Could not find a method:
body: <p>I have an android program that crashes and I get an error in LogCat:</p>
  
  <pre><code>E/AndroidRuntime(21504): FATAL EXCEPTION: main
  E/AndroidRuntime(21504): java.lang.IllegalStateException: Could not find a 
  method sendMesage(View) in the activity class com.example.test.MainActivity 
  for onClick handler on view class android.widget.Button
  </code></pre>
  
  <p>Here is my main activity:</p>
  
  <pre><code>public class MainActivity extends Activity {
      public final static String EXTRA_MESSAGE = "com.example.test.MESSAGE";
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
          }
  
          @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;
          }
  
          public void sendMessage(View view) {
              Intent intent = new Intent(this, DisplayMessageActivity.class);
              EditText editText = (EditText) findViewById(R.id.edit_message);
              String message = editText.getText().toString();
              intent.putExtra(EXTRA_MESSAGE, message);
              startActivity(intent);
          }
      }
  </code></pre>
  
  <p>Here is my DisplayMessageActivity:</p>
  
  <pre><code>public class DisplayMessageActivity extends Activity {
  
      @SuppressLint("NewApi")
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_display_message);
          // Show the Up button in the action bar.
          setupActionBar();
  
          Intent intent = getIntent();
          String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  
          TextView textView = new TextView(this);
          textView.setTextSize(40);
          textView.setText(message);
  
          setContentView(textView);
      }
  
      /**
       * Set up the {@link android.app.ActionBar}, if the API is available.
       */
      @TargetApi(Build.VERSION_CODES.HONEYCOMB)
      private void setupActionBar() {
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
              getActionBar().setDisplayHomeAsUpEnabled(true);
          }
      }
  
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
              // This ID represents the Home or Up button. In the case of this
              // activity, the Up button is shown. Use NavUtils to allow users
              // to navigate up one level in the application structure. For
              // more details, see the Navigation pattern on Android Design:
              //
              // http://developer.android.com/design/patterns/
                      // navigation.html#up-vs-back
              //
              NavUtils.navigateUpFromSameTask(this);
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>I have invoked the method sendMessage correctly in the MainActivity, where is the misspelled method defined?</p>