Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9063933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:07:21+00:00 2026-06-16T16:07:21+00:00

I am working on an audio application, but it crashes when trying to create

  • 0

I am working on an audio application,
but it crashes when trying to create the PCM file, here the code:

public class RecordPCM {

public void record() {

    Log.d("mensaje","Recording testeo started");



    int frequency = 11025;
    //int channelConfiguration = AudioFormat.CHANNEL_CONFIGURATION_MONO;

    int channelConfiguration = AudioFormat.CHANNEL_IN_MONO; //cambiado por el de arriba por deprecado


    int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
    File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/reverseme.pcm");




    // Delete any previous recording.
    if (file.exists()) {
    file.delete();
    Log.d("mensaje","file exists!!!");

    }


    // Create the new file.
    try {
    file.createNewFile();
    } catch (IOException e) {
    throw new IllegalStateException("Failed to create :::: " + file.toString());
    }

    try {
    // Create a DataOuputStream to write the audio data into the saved file.
    OutputStream os = new FileOutputStream(file);
    BufferedOutputStream bos = new BufferedOutputStream(os);
    DataOutputStream dos = new DataOutputStream(bos);

    // Create a new AudioRecord object to record the audio.
    int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
    AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, 
    frequency, channelConfiguration, 
    audioEncoding, bufferSize);

    short[] buffer = new short[bufferSize]; 
    audioRecord.startRecording();


    boolean isRecording = false; //metido para arreglar

    while (isRecording) {
    int bufferReadResult = audioRecord.read(buffer, 0, bufferSize);
    for (int i = 0; i < bufferReadResult; i++)
    dos.writeShort(buffer[i]);
    }


    audioRecord.stop();
    dos.close();

    } catch (Throwable t) {
    Log.d("mensaje","Recording Failed");
    }

}

public void copio(){
    Log.d("mensaje","Recording testeo");

}
}

so when I call

recordObject.record();

The app crashes with the error:

?:??: W/?(?): FATAL EXCEPTION: main
?:??: W/?(?): java.lang.IllegalStateException: Could not execute method of the activity
?:??: W/?(?):   at android.view.View$1.onClick(View.java:3597)
?:??: W/?(?):   at android.view.View.performClick(View.java:4202)
?:??: W/?(?):   at android.view.View$PerformClick.run(View.java:17340)
?:??: W/?(?):   at android.os.Handler.handleCallback(Handler.java:725)
?:??: W/?(?):   at android.os.Handler.dispatchMessage(Handler.java:92)
?:??: W/?(?):   at android.os.Looper.loop(Looper.java:137)
?:??: W/?(?):   at android.app.ActivityThread.main(ActivityThread.java:5039)
?:??: W/?(?):   at java.lang.reflect.Method.invokeNative(Native Method)
?:??: W/?(?):   at java.lang.reflect.Method.invoke(Method.java:511)
?:??: W/?(?):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
?:??: W/?(?):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
?:??: W/?(?):   at dalvik.system.NativeStart.main(Native Method)
?:??: W/?(?): Caused by: java.lang.reflect.InvocationTargetException
?:??: W/?(?):   at java.lang.reflect.Method.invokeNative(Native Method)
?:??: W/?(?):   at java.lang.reflect.Method.invoke(Method.java:511)
?:??: W/?(?):   at android.view.View$1.onClick(View.java:3592)
?:??: W/?(?):   ... 11 more
?:??: W/?(?): Caused by: java.lang.IllegalStateException: Failed to create :::: /storage/emulated/0/reverseme.pcm
?:??: W/?(?):   at com.hyper.reverspeech.RecordPCM.record(RecordPCM.java:48)
?:??: W/?(?):   at com.hyper.reverspeech.ReverSpeechActivity.buttonRecPressed(ReverSpeechActivity.java:20)

So

  1. what is making my app crash,

  2. Why is my logCat shown with ? question marks??,

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T16:07:22+00:00Added an answer on June 16, 2026 at 4:07 pm

    The cause of your “crash” is that your application is throwing am IllegalStateException when it tries (and fails) to create the file. Why you are getting an IOException is anyone’s guess. You are throwing away the evidence! (Hint: use the IllegalStateException constructor that includes an exception argument … and pass e)

    The question marks in your logcat output could be explained by these:

    • Debugging Issues (Android Eclipse)
    • Why is LogCat showing all items as warnings (orange)?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on understanding Core Audio, or rather: Extended Audio File Services Here,
I am trying to stream audio to my flash application. I got it working
I am working on an application where I need to stat the audio file
durCurrently i am working in iPhone application, Using AVAudioPlayer to play the audio file
I'm working on an application that samples audio and needs to do real time
I am using MPMoviePlayerController in Ipad application. Video is not showing but audio comes,
I'm working on an audio application, written in C. I need to provide live
I have an application for audio/video call using SIP protocol.It working fine when i
The Problem I'm working on a web application where users can sequence audio samples
I have finished the majority of my application that I am working on, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.