When I try to record audio through my Nexus 5 using the following code
record = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_8BIT, BYTE_OF_SAMPLE * bufferSampleSize); record.startRecording();
Then I get the following exceptions in logcat:
E/AudioRecord: AudioFlinger could not create record track, status: -1 E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -1. E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object. E/AndroidRuntime: FATAL EXCEPTION: Thread-855 E/AndroidRuntime: Process: com.*.*, PID: 14206 E/AndroidRuntime: java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord. E/AndroidRuntime: at android.media.AudioRecord.startRecording(AudioRecord.java:885) E/AndroidRuntime: at com.*.*.MainActivity$Looper.run(MainActivity.java:265) E/Surface: getSlotFromBufferLocked: unknown buffer: 0x9e476d00
I added the following line to the manifest file.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
I tested an AudioRecord object not initializing . None of these solutions work.
But his work is in another project. Is something missing?
source share