I'm new developer in android development i have two apps in play store but my apps now is not working with android 6 & android 7 i get this messages
runtimeException and NullPointerException
this my main activity code i have problem with:
public class Recored extends Activity {     
Button rec,stop;
private MediaRecorder myRecords;
private String outputFile = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.recored);
    stop = (Button)findViewById(R.id.bStop);
    rec = (Button)findViewById(R.id.bRecord);
    stop.setEnabled(false);
    myRecords = new MediaRecorder();
    myRecords.setAudioSource(MediaRecorder.AudioSource.MIC);
    myRecords.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    myRecords.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    Date createdDate = new Date();
    File myDir = new File(Environment.getExternalStorageDirectory()+"/Recordings");
    if (!myDir.exists()){
        if (myDir.mkdir());
    }
        outputFile = myDir.getAbsolutePath() + "/" + createdDate + ".mp3";
        myRecords.setOutputFile(outputFile);
        rec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    myRecords.prepare();
                    myRecords.start();
                }
                catch (IllegalStateException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                catch (IOException e) {
                    e.printStackTrace();
                }
                rec.setEnabled(false);
                stop.setEnabled(true);
                Toast.makeText(getApplicationContext(),"Recording started",Toast.LENGTH_LONG).show();
            }
        });
        stop.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                myRecords.stop();
                myRecords.release();
                myRecords = null;
                stop.setEnabled(false);
                rec.setEnabled(true);
            }
        });
}
}
 
     
     
    