When I press my button that start the recording I get this exception:
I am running on a motorola Android device Moto G5S
D/AudioRecorder(29157): Start
D/AudioRecorder(29157): /storage/emulated/0.m4a
E/AudioRecorder(29157): prepare() failed
E/MediaRecorder(29157): start called in an invalid state: 4
E/MethodChannel#audio_recorder(29157): Failed to handle method call
E/MethodChannel#audio_recorder(29157): java.lang.IllegalStateException
E/MethodChannel#audio_recorder(29157): at android.media.MediaRecorder.start(Native Method)
E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.startRecording(AudioRecorderPlugin.java:107)
E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:59)
E/MethodChannel#audio_recorder(29157): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191)
E/MethodChannel#audio_recorder(29157): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163)
E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.next(MessageQueue.java:323)
E/MethodChannel#audio_recorder(29157): at android.os.Looper.loop(Looper.java:136)
E/MethodChannel#audio_recorder(29157): at android.app.ActivityThread.main(ActivityThread.java:6165)
E/MethodChannel#audio_recorder(29157): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888)
E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
When I press my button that start the recording I get this exception: I am running on a motorola Android device Moto G5S
D/AudioRecorder(29157): Start D/AudioRecorder(29157): /storage/emulated/0.m4a E/AudioRecorder(29157): prepare() failed E/MediaRecorder(29157): start called in an invalid state: 4 E/MethodChannel#audio_recorder(29157): Failed to handle method call E/MethodChannel#audio_recorder(29157): java.lang.IllegalStateException E/MethodChannel#audio_recorder(29157): at android.media.MediaRecorder.start(Native Method) E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.startRecording(AudioRecorderPlugin.java:107) E/MethodChannel#audio_recorder(29157): at com.jordanalcaraz.audiorecorder.audiorecorder.AudioRecorderPlugin.onMethodCall(AudioRecorderPlugin.java:59) E/MethodChannel#audio_recorder(29157): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:191) E/MethodChannel#audio_recorder(29157): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#audio_recorder(29157): at android.os.MessageQueue.next(MessageQueue.java:323) E/MethodChannel#audio_recorder(29157): at android.os.Looper.loop(Looper.java:136) E/MethodChannel#audio_recorder(29157): at android.app.ActivityThread.main(ActivityThread.java:6165) E/MethodChannel#audio_recorder(29157): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:888) E/MethodChannel#audio_recorder(29157): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
My code that executes the recording is: