title: Error: Activity class {.MainActivity} does not exist
body: <p>I tried to run my android application in my android device but it keeps saying that my Main Activity does not exist although my Main Activity class is there</p>
  
  <p>I tried to create a new project then copied my previous codes and it worked for a while. But then it produced the same error again.</p>
  
  <pre><code>Error while executing: am start -n "com.example.sms/com.example.sms.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
  Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.sms/.MainActivity }
  Error type 3
  Error: Activity class {com.example.sms/com.example.sms.MainActivity} does not exist.
  
  Error while Launching activity
  
  
  </code></pre>
  
  <p>There is already a intent-filter in may android manifest:</p>
  
  <pre><code>        &lt;activity android:name=".MainActivity"&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;
  </code></pre>
  
  <p>I already tried to clean and rebuild project. But it still gets the same error. My android device's version is android 9.</p>
  
  <p>Here is my main activity:</p>
  
  <pre><code>package com.example.sms;
  
  import androidx.annotation.NonNull;
  import androidx.appcompat.app.AppCompatActivity;
  import androidx.core.app.ActivityCompat;
  import androidx.core.content.ContextCompat;
  
  import android.Manifest;
  import android.content.Intent;
  import android.content.pm.PackageManager;
  import android.net.Uri;
  import android.os.Bundle;
  import android.telephony.SmsManager;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import java.util.ArrayList;
  
  public class MainActivity extends AppCompatActivity implements View.OnClickListener {
  
      EditText etNumber, etMessage;
      Button btnSend;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          etNumber = (EditText)findViewById(R.id.etNumber);
          btnSend = (Button)findViewById(R.id.btnSend);
          btnSend.setOnClickListener(this);
  
      }
  
      public void MyMessage() {
  
          String phoneNum = etNumber.getText().toString().trim();
          String spamMessage = "Hi";
  
          if (etNumber.getText().toString().equals("09152006203")) {
              if (!etNumber.getText().toString().equals("")) {
                  SmsManager smsManager = SmsManager.getDefault();
                  ArrayList&lt;String&gt; sms = smsManager.divideMessage(spamMessage);
                  smsManager.sendMultipartTextMessage(phoneNum, null,sms,null, null);
  
                  Toast.makeText(this, "Message has been sent", Toast.LENGTH_SHORT).show();
  
              } else {
                  Toast.makeText(this, "Please enter number or message", Toast.LENGTH_SHORT).show();
              }
          } else {
              Toast.makeText(this, "Number is incorrect!", Toast.LENGTH_SHORT).show();
          }
      }
  
      @Override
      public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
          super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  
          switch(requestCode){
  
              case 0:
                  if(grantResults.length&gt;=0 &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED){
                      MyMessage();
                  } else {
                      Toast.makeText(this, "You do not have required permission", Toast.LENGTH_SHORT).show();
                  }
          }
      }
  
      @Override
      public void onClick(View v) {
          int permissionCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS);
  
          if(permissionCheck == PackageManager.PERMISSION_GRANTED){
              MyMessage();
          }
          else{
              ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.SEND_SMS}, 0);
          }
  
  
      }
  }
  
  </code></pre>