JBaba
JBaba

Reputation: 610

Android emulator no sound in ubuntu

I am running android emulator in ubuntu-19.10 and I have attempted following solutions with no results,

Link-1

Link-2

Link-3

Error,

1:10 PM Emulator: pulseaudio: pa_context_connect() failed
1:10 PM Emulator: pulseaudio: Reason: Connection refused
1:10 PM Emulator: pulseaudio: Failed to initialize PA contextaudio: Could not init `pa' audio driver

Some notes on solution I tried,

When trying Link-1 i don't see "Qemu-system" in settings. Also created many different versions of AVDs but does seem to work.

After trying Link-2 pulseaudio -D command errors out.

I have also tried Link-3 which looks like widely suggested solution in multiple blog posts. But still I find the same error on emulator startup. I would like to note that I am not smart enough understand this solution.

Thanks in advance for helping out.

Upvotes: 9

Views: 7678

Answers (7)

Tarik Cisco
Tarik Cisco

Reputation: 11

OS : Ubuntu 20.04. Android studio (snap).

I tried all the methods, none worked for me.

By installing these libs, the sound works now.

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

as Gigi mentionned before

Upvotes: 0

Rony Mesquita
Rony Mesquita

Reputation: 559

On Ubuntu, is possible open the emulator with terminal and change the sound in System Preferences. Works with the instant version of Android Studio. It works with the snap version of Android Studio.

First is needed to add the emulator command to the PATH.

This can be done by editing .bashrc or .zshrc. Preferably these lines should be placed at the end of the file.

export ANDROID_SDK_PATH=$HOME/Android/Sdk
export ANDROID_NDK_PATH=$HOME/Android/Sdk/ndk
export PATH="$PATH:$HOME/Android/Sdk/platform-tools"
export PATH="$PATH:$HOME/Android/Sdk/emulator"

The PATH variable needs to be reloaded. This can be done manually, as shown below, or simply by opening another terminal:

source ~/.bashrc
# OR
source ~/.zshrc

Another way is to add adb and android-sdk-platform-tools-common packages to have the emulator command available. Package names may vary depending on the Ubuntu version.

After that, the emulator command can be used to list available emulators:

emulator -list-avds

Example of output:

Pixel_4_API_30
Pixel_C_API_30

Then can be opened one of the available emulators:

emulator @Pixel_4_API_30

Finally, the emulator probably will appear at the System Preferences:

Sound Settings on Ubuntu

Upvotes: 2

Emmanuel Murairi
Emmanuel Murairi

Reputation: 401

I had the same issue, runing Intellij on Ubuntu 20.04. I solved it by adapting a solution from this link

I run this:

sudo ln -s /run/user/1000/pulse/native /run/user/1000/snap.intellij-idea-community/pulse

If you're using Android studio, just try to find "snap.intellij-idea-community" will be named differently, referring to your android studio installation.

Upvotes: 2

Gigi
Gigi

Reputation: 103

I was having a similar issue on Ubuntu 20.04 but I fixed it by uninstalling the store version of Android Studio and following the installation instructions on the Official Android Studio website here: https://developer.android.com/studio/install

  1. If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386
    lib32z1 libbz2-1.0:i386
  1. To install Android Studio on Linux, proceed as follows:

Unpack the .zip file you downloaded to an appropriate location for your applications, such as within /usr/local/ for your user profile, or /opt/ for shared users. If you're using a 64-bit version of Linux, make sure you first install the required libraries for 64-bit machines.

To launch Android Studio, open a terminal, navigate to the android-studio/bin/ directory, and execute studio.sh. Select whether you want to import previous Android Studio settings or not, then click OK. The Android Studio Setup Wizard guides you through the rest of the setup, which includes downloading Android SDK components that are required for development.

Upvotes: 2

Pedro Gonzalez
Pedro Gonzalez

Reputation: 1459

Same problem in Ubuntu 20.04, with Android Studio installed from Ubuntu Software. Tried everything (paprefs, this), nothing worked. Uninstall Android Studio Snap and reinstall from tar package downloaded from Android Studio website, works perfect.

Upvotes: 6

Mo'ath Alshorman
Mo'ath Alshorman

Reputation: 181

I got crazy while trying to solve this issue but finally, it was solved. I figured out that we have to enable multiple simultaneous audio outputs in order to hear both sounds the emulator and the OS.

The solution is by installing paprefs small app as the following.

1- Install it:

$ sudo apt install paprefs

2- Open it:

$ paprefs

3- Go to the last tab Simultaneous Output and click on the only option there in order to enable the Simultaneous Output.

enter image description here

4- Restart it:

$ pulseaudio -k

5- If it fails then you have to restart the daemon

$ pulseaudio -D

6- Almost finished, go to the system settings and navigate to Sounds options and change the output sounds to the newly added one as below.

enter image description here

Upvotes: 0

intr0
intr0

Reputation: 81

If this is a Snap it's got strict requirements as far as i/o; that said, if the requirements are similar to those of running Androidx86 using Vbox on Debian (I realize Qemu is a different environment, however, this may be of use for both Jbaba as well as future reference. Step one: make sure that you belong to the group Qemu (or the equivalent for Ubuntu/Snap?). Step two: make sure you belong to the group pulseaudio. Step three: make sure that Qemu is explicitly permitted to access whatever your audio output device is and that it's the device that pulseaudio is configured to output to. There should be a fairly intuitive way of seeing this using Qemu (it's been awhile, so I am not able to tell you where to find it). As for pulseaudio; its GUI will show you.

Upvotes: 0

Related Questions