title: Android AudioRecord initialization fails every time
body: <p>My problem is simple to explain -- I am trying to create a AudioRecord object but it fails to initialize (ie after the constructor, getState returns 0, indicating failure).  I am running this from Eclipse on a MotoDroid 1 running OS 2.2.1.  My AndroidManifest.xml is, AFAIK, using the right permission, RECORD_AUDIO (I don't know how to confirm this):</p>
  
  <pre><code>&lt;application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"&gt;
      &lt;uses-permission android:name="android.permission.RECORD_AUDIO"/&gt;
      &lt;activity android:name=".SphinxMic"
                android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  </code></pre>
  
  <p>I do the following to create the AudioRecord:</p>
  
  <pre><code>bufferSize = AudioRecord.getMinBufferSize(8000, CHANNEL_IN_MONO, ENCODING_PCM_8BIT);
  audioRecorder = new AudioRecord(AudioSource.MIC, 8000, CHANNEL_IN_MONO, ENCODING_PCM_8BIT, 50*bufferSize);
  if (audioRecorder.getState() != AudioRecord.STATE_INITIALIZED)
    throw new Exception("AudioRecord init failed");
  </code></pre>
  
  <p>audioRecorder.getState() returns 0 (ie STATE_UNINITIALIZED)</p>
  
  <p>I have not found any complete examples of using this API and I'm very much an Android beginner so the solution may well be something simple.  What can I do to find out why it fails?</p>
  
  <p>A few people have asked similar questions, but they must have been having different problems than me because the fixes they approve haven't helped me.  Most notably <a href="https://stackoverflow.com/questions/4161666/android-audiorecord-fails-to-initialize">this</a>.  But the approved solution is perplexing and didn't work for me anyway.  I have also tried a variety of bit rates (8000, 16000, 11025, 44100), both mono and stereo and 8 and 16 bit.  No combination comes back as successfully initialized.</p>