Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 245
JBaba Avatar asked Feb 22 '20 19:02

JBaba


People also ask

How do I enable audio in Ubuntu?

Third alternate method: Try alsamixer Check if the speakers or your desired audio output is muted here. MM means mute and OO means unmute. If your desired audio output (mostly it's speakers) or the Master is muted, unmute it. You can exit the screen using Esc key.


4 Answers

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.

like image 159
Pedro Gonzalez Avatar answered Oct 17 '22 03:10

Pedro Gonzalez


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.

like image 26
Gigi Avatar answered Oct 17 '22 01:10

Gigi


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.

like image 38
Emmanuel Murairi Avatar answered Oct 17 '22 02:10

Emmanuel Murairi


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

like image 2
Rony Mesquita Avatar answered Oct 17 '22 02:10

Rony Mesquita