question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

stop() called on an uninitialized AudioRecord.

See original GitHub issue

Hi, I am using this library and when I am recording second time and stopping, I am getting below error. Please suggest. Thank You.

Error is

java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.

**Code to start and stop **

`View.OnTouchListener touchListener = new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (permissionToRecordAccepted && permissionToReadExternalStorage && permissionToWriteExternalStorage) {

                //startPulseAnimation();
                timerTextView.setVisibility(View.VISIBLE);
                countDownTimer.start();
                recorder.startRecording();
            }


        } else if (event.getAction() == MotionEvent.ACTION_UP) {

            timerTextView.setVisibility(View.INVISIBLE);
            countDownTimer.cancel();
            try {
                recorder.stopRecording(); // Here I am getting error.
                if (!TextUtils.isEmpty(mVerificationId)) {
                    mPresenter.configureVoice(mVerificationId, Utility.getDeviceId(), file().getPath(), audioBytes);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        return true;
    }
}`

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dbof10commented, Aug 30, 2018

from AOSP,

after stop is called, mState = STATE_UNINITIALIZED; from startRecording ,

if (mState != STATE_INITIALIZED) {
           throw new IllegalStateException("startRecording() called on an "
                   + "uninitialized AudioRecord.");
       }

mState only resets from the constructor => construct new object for second record

0reactions
kailash09dabhicommented, Jul 18, 2018

java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord. You will get this error only when the AudioRecord object is not properly intialized. It may happen if you use stopRecording() before calling startRecording().

Read more comments on GitHub >

github_iconTop Results From Across the Web

startRecording() called on an uninitialized AudioRecord
IllegalStateException: startRecording() called on an uninitialized AudioRecord. But when i set the audiosource to "MIC", it works fine, ...
Read more >
How to catch exception thrown from AudioRecord Class in ...
When i am trying to stop the AudioRecord class using JNI jmethodID method_id; ... startRecording() called on an uninitialized AudioRecord.
Read more >
Java – startRecording() called on an uninitialized AudioRecord
i am trying to record voice call on android. I am using AudioRecord class/api of android to perform this. But for some reason...
Read more >
media/java/android/media/AudioRecord.java - Google Git
throw new IllegalStateException("stop() called on an uninitialized AudioRecord."); } // stop recording. synchronized(mRecordingStateLock) {.
Read more >
android.media.AudioRecord#STATE_INITIALIZED
VISIBLE); } else { uncaughtException(Thread.currentThread(), new IllegalStateException ("startRecording() called on an " + "uninitialized AudioRecord.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found