Tek Eye Logo

Tek Eye

AVD Sound Playback for Android App Testing

Update: This article refers to the old Eclipse based Android development environment. This article has been archived and is kept for historical purposes only.

A sound signal

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 headphones 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:

  • Is the PC volume turned up and sound muting off?
  • Are speakers plugged in? Or headphones in the headphone jack?
  • 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 AVD solution for no AVD sound. (Please ensure that the Android SDK is up to date as well).

Uncheck Launch from snapshot

Open 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 the Launch from snapshot option may be checked.

Checking AVD Launch Options For No AVD Sound Issue

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 https://stackoverflow.com/, to search for or ask for suggestions to your specific problem.

Mike Bugdroid the Android Logo

See Also

For a full list of all the articles in Tek Eye see the full site Index.

Author:  Published:  Archived:

ShareSubmit to TwitterSubmit to FacebookSubmit to LinkedInSubmit to redditPrint Page

Do you have a question or comment about this article?

(Alternatively, use the email address at the bottom of the web page.)

 This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

markdown CMS Small Logo Icon ↓markdown↓ CMS is fast and simple. Build websites quickly and publish easily. For beginner to expert.

Articles on:

Android Programming and Android Practice Projects, HTML, VPS, Computing, IT, Computer History, ↓markdown↓ CMS, C# Programming, Using Windows for Programming

Free Android Projects and Samples:

Android Examples, Android List Examples, Android UI Examples

Tek Eye Published Projects