title: App keeps closing
body: <p>I am making an app that records and plays audio, but when I try to run it, it closes. Here is my java:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  private MediaPlayer mp;
  public int isPlaying = 0;
  MediaRecorder recorder = new MediaRecorder();
  public int isRecording = 0;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      ImageButton button = findViewById(R.id.pressbutton);
      button.setOnTouchListener(handleTouch);
      mp = MediaPlayer.create(this, R.raw.test);
      mp.setLooping(true);
  
      recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
      recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      recorder.setOutputFile("R.raw.test");
  
  }
  
  
          return true;
      }
  };
  
  public void play() {
      mp.start();
      Log.d("MediaPlayer", "started");
      isPlaying = 1;
  }
  
  public void pause() {
      mp.pause();
      Log.d("MediaPlayer", "paused");
      isPlaying = 0;
  }
  
  public void recorder(View v){
      if (isRecording == 0) {
          try {
              recorder.prepare();
              recorder.start();
              isRecording = 1;
          } catch (IOException e) {
              e.printStackTrace();
          }
      }else if(isRecording == 1){
          recorder.stop();
          isRecording = 0;
      }
  }
  
  }
  </code></pre>
  
  <p>Any help would be appreciated. Thanks in advance. And, to be clear, Android Studio is not giving me any clue to the errors. I had to leave out some part so it would fit in stackoverflow.</p>