This error may come when using Intent, and compiler throws above error. Possible solution for the above are

  • Check the import statements at the top and make sure it includes the line:
    import android.content.Intent;
  • Make sure both Activities are defined in your Manifest file.
    Intent intent = new Intent(this, NextActivity.class);
  • Make sure the class dependencies are added in gradle.
    dependencies {
        implementation 'androidx.viewpager:viewpager:1.0.0'