Can't record with Media Plugin on Android


#1

I have this piece of code to record an audio file:

    let nomeArquivo = 'testeAndroid.'+ (this.plataforma.is('ios') ? 'm4a' : 'aac');
    let dir = this.file.dataDirectory;
    
    this.file.createFile(dir, nomeArquivo, true).then((fileEntry: FileEntry)=>{
      console.log(fileEntry);
      console.log(fileEntry.nativeURL);
      this.audio = this.media.create(this.plataforma.is('ios') ? fileEntry.nativeURL.substring(8) : fileEntry.nativeURL);
      this.audio.onSuccess.subscribe(status=> console.log('Novo status: '+status));
      this.audio.onError.subscribe(erro => {console.log('ON ERROR: ');console.log(erro)});
      this.audio.onSuccess.subscribe(sucesso=> {console.log('ON SUCCESS');console.log(sucesso)});
      this.audio.startRecord();
      console.log('Gravando...');
    }).catch(erro => console.log(erro));

It works fine on iOS but gives me MEDIA_ERROR.ABORTED on Android after start record is called.

file:///data/user/0/br.com.blueservice.app/files/testeAndroid.aac
Gravando…
ON ERRO: Object: code : 1 (ABORTED)

What could cause this error code?
Thank you in advance.