AVD Sound Playback for Android App Testing

No AVD Sound When Testing an Android App?

On creating an Android Virtual Device (AVD) audio playback is normally OK. However, if using an old saved AVD there may be no AVD sound. When this happens messages may be seen in LogCat, including one or more of the following. (It varies by the API level of the AVD.):

AudioTrack Error obtaining an audio buffer, giving up.

AudioTrack obtainBuffer timed out (is the CPU pegged?).

AudioFlinger could not create track, status: -12.

Be aware that the last error is also seen with other sound playback issues. These other issues are usually memory related: such as the audio file is to big; too much data in the file (e.g. sample rate to high or varies to much); or the limit (32) on the number of audio tracks attempting to be played has been reached.

Note: If you don’t see messages in LogCat the following solutions may still apply. But also check that the PC’s sound is not off! (Or turned down low). Even forgetting to unplug headphone may be why you have no AVD sound.

Solutions to Try When You Can’t Play AVD Sound

In earlier editions of the Android Software Development Kit (SDK) the AVDs may not have been created with audio playback enabled. Subsequent SDKs enabled audio when an AVD was created. If an AVD is started and there is no AVD sound try the following:

  • Uncheck Launch from snapshot when starting the AVD.
  • Edit the AVD config.ini file to set Audio playback support to yes.
  • Delete the AVD and recreate it.
  • Use a physical Android device.

He is a bit more detail on each solution for no AVD sound. (Please ensure that the Android SDK is up to date as well).

Uncheck Launch from snapshot

Checking AVD Launch Options For No AVD Sound IssueOpen Android Virtual Device Manager by clicking the icon on the Eclipse toolbar or using the option in the Window menu. Select the relevant AVD. Press the Start button. When the Launch Options dialog appears (see right) the Launch from snapshot option may be checked. Make sure that Launch from snapshot is unchecked. Press Launch. The AVD snapshot configured without audio playback will be deleted. (Anything else stored on the snapshot is also lost.) When the AVD is closed a new snapshot is created (if Save to snapshot is checked).

Edit the AVD config.ini File

Starting an AVD fresh without an old snapshot will not work if the AVD is explicitly configured without audio support. Select the AVD in the AVD Manager and select the Edit button. The Edit Android Virtual Device dialog will be displayed differently depending upon how the AVD has been defined (e.g. from an earlier SDK). This image shows two different edit screens for AVD definitions:

Different AVD Edit Dialogs When Dealing with No AVD Sound

If the Hardware section exists make sure an entry for Audio playback support is not set to No, change it if necessary. If no Hardware section is available open the configuration file for the AVD. Where is the AVD configuration file? On a Windows machine this is in the .android directory for the logged on user (normally under the Users folder). In this .android folder is a avd directory containing all the defined AVDs. Open the relevant .avd folder and edit the config.ini file. (The name of the AVD matches the folder name.) Add the setting hw.audioOutput=yes and save the config.ini file.

Run the AVD again to ensure that the AVD sound is on.

This error message may be seen when restarting the AVD:

emulator: ERROR: Unable to load VM from snapshot. The snapshot has been saved for a different hardware configuration.

Because the hardware configuration has changed any snapshot will be invalid. See the previous solution on running the AVD to clear an old snapshot.

Deleting the AVD

In the AVD Manager use the Delete button to remove the AVD that has no sound playback. Recreate it using the New button. See the previous solution if the new AVD does not have audio playback enabled by default.

As a Last Resort

Hopefully one of the solutions above has solved the no AVD sound issue. If you cannot get audio playback working on an AVD you may need to use a physical Android device until the issue has been solved. Try a online forum, such as http://stackoverflow.com, to search for or ask for suggestions to your specific problem.

Leave a Reply

Your email address will not be published. Required fields are marked *

Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.