Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
KVM and trouble with Android Studio
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
EugeneTheJeep
Tux's lil' helper
Tux's lil' helper


Joined: 17 May 2017
Posts: 101

PostPosted: Fri Jul 07, 2017 10:35 pm    Post subject: KVM and trouble with Android Studio Reply with quote

Hi all,

I recently reconfigured my kernel with KVM support using this guide https://wiki.gentoo.org/wiki/QEMU#Kernel

Android Studio requires KVM to emulate Android devices and initially, when I tried to run a project, it gave me the error that /dev/kvm could not be found. Now I don't get that error, but when I run a project, it gets stuck on "Waiting for target device to come online" and times out after 300 seconds. I googled around and found that Linux/Mac users have run into this problem, but couldn't find anything gentoo specific. I've tried several proposed solutions, but nothing that worked din my case.

So far I've tried:

1 Stop & restart the emulator
AVD manager-> right-click on the emulator you are using -> Stop
(didn't work because the emulator never started in the first place, so 'Stop' was always greyed out. even if I started the emulator manually, it would show a progress bar saying "starting AVD", which, when finished, did not start the device, and, when the progress bar completed, 'Stop' was still greyed out)

2 Reinstall the emulator
Tools - Android - SDK Manager - SDK Tools - Android Emulator - uncheck, apply, check, apply, then start the emulator
(didn't work. again, the emulator starts then crashes like in step 1)

3 Change graphics performance emulation from "Automatic/Hardware" to "Software"
(didn't work, same results as 1 and 2, where is is "waiting for target device to come online"

I tried the above solutions with a virtual Nexus 6P device using both Android API 23 (Marshmallow) and Android API 26 (Android "O")

As far as I can tell the emulator isn't even starting, so changing graphics performance to software would be completely irrelevant.Reinstalling the emulator module didn't work, even after restarting the entire IDE, and stopping/restarting the emulator didn't work (again it doesn't appear to start in the first place).

To sum up I'm pretty sure the problem is that the virtual devices won't start in the first place, i.e. the Android emulator won't run, even though the the IDE recognizes that /dev/kvm exists.

Are there any users of Android Studio or Gentoo experts out there that might know what is going on with this and if there is a fix for it? Any help is greatly appreciated!
Back to top
View user's profile Send private message
EugeneTheJeep
Tux's lil' helper
Tux's lil' helper


Joined: 17 May 2017
Posts: 101

PostPosted: Sat Jul 08, 2017 2:11 pm    Post subject: Reply with quote

So I tried running the emulator from the command line and got the following error:

Code:

~/Android/Sdk/emulator $ ./emulator -avd Nexus_6P_API_23 23
/home/jeep/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-i386: error while loading shared libraries: libpulse.so.0: cannot open shared object file: No such file or directory


I googled around for libpulse.so.0 and it appears to be a compiled llibrary file for libpulse0.

I searched for the file and incidentally found it in my Steam directory:

Code:

$ find /home/jeep | grep libpulse.so.0
/home/jeep/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libpulse.so.0.13.5
/home/jeep/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/usr/lib/x86_64-linux-gnu/libpulse.so.0
/home/jeep/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libpulse.so.0.13.5
/home/jeep/.local/share/Steam/ubuntu12_32/steam-runtime/i386/usr/lib/i386-linux-gnu/libpulse.so.0


So maybe the reason the emulator doesn't start is because it's looking for this library? I googled around and it seems to be a package available for RedHat and Debian-based systems. But how can I ascertain where Android Studio is trying to find this file and how can I make it find it, since it's apparently already available on my system, albeit not where it's looking?

Maybe install pulseaudio? (I'd rather not, it seems like a whole lot of trouble, and it's a separate package from libpulse0 on Ubuntu, so I dont think it contains the file I need anyways)
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sat Jul 08, 2017 3:29 pm    Post subject: Reply with quote

Steam bundles private copies of system libraries instead of using the system libraries installed by the package manager. It is not unusual to find non-Steam libraries in its directory, but you may not be able to reuse them for anything else because they may be an incompatible version (or not - you can try it, but I would not be optimistic).

The package for Android Studio should have depended on a package which would provide libpulse for you (and it should not be bundling its own copy of qemu). Qemu has optional support for PulseAudio. It appears that the qemu bundled with Android Studio was built with USE=pulseaudio. Perhaps if you use a Qemu built with USE=-pulseaudio, Android Studio will work for you. Could you link to the package which you used to install Android Studio?
Back to top
View user's profile Send private message
EugeneTheJeep
Tux's lil' helper
Tux's lil' helper


Joined: 17 May 2017
Posts: 101

PostPosted: Sat Jul 08, 2017 4:01 pm    Post subject: Reply with quote

I installed Android Studio using this package: https://gitweb.gentoo.org/repo/gentoo.git/tree/dev-util/android-studio/android-studio-2.3.2.0.162.3934792.ebuild
(the stable version in Portage)

But when you initally emerge the package, it doesn't come with the android emulator installed. You use Android Studio's SDK manager to install the emulator like so:

Tools->Android->SDKManager, select "SDK Tools" tab, check the box labeled "Android Emulator", then press "Apply".
The SDK manager then downloads the emulator from https://dl.google.com/android/repository/emulator-linux-3965150.zip, decompresses, and installs under ~/Android/Sdk/emulator

The bundled qemu binaries (there are many) are found under ~/Android/Sdk/emulator/qemu/linux-x86_64:

Code:

qemu-system-aarch64  qemu-system-mips64el  qemu-upstream-aarch64  qemu-upstream-mips64el
qemu-system-armel    qemu-system-mipsel    qemu-upstream-armel    qemu-upstream-mipsel
qemu-system-i386     qemu-system-x86_64    qemu-upstream-i386     qemu-upstream-x86_64


I'm pretty sure they come configured with pulseaudio from Google's own repository for whatever reason.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 21724

PostPosted: Sat Jul 08, 2017 5:13 pm    Post subject: Reply with quote

Now that you describe it, I recall that there is some weirdness with Android development. I don't recall details, but I want to say that I was told there was some absurd licensing problem that led to the unfortunate implementation of downloading the packages prebuilt from Google instead of properly managing them in the package manager. I would say you should complain to Google to stop bundling Qemu without its dependencies, but I know that will go nowhere. If you can figure out how those Qemu instances were built and build instances that, aside from setting USE=-pulseaudio on yours, match their build configuration, you could try replacing their bundled copies with locally built ones. Otherwise, you will likely be stuck installing either Pulseaudio or, if you are lucky, a compatibility shim.

In principle, rebuilding Qemu like that should be easy, since most of it is under the GPL and any good redistributor will of course fulfill their GPL obligations in a timely and reasonably recipient friendly manner.
Back to top
View user's profile Send private message
EugeneTheJeep
Tux's lil' helper
Tux's lil' helper


Joined: 17 May 2017
Posts: 101

PostPosted: Sat Jul 08, 2017 7:23 pm    Post subject: Reply with quote

Thanks for the feedback. I tried emerging a 32-bit qemu and then doing a symbolic link into the Android emulator directory, and it gave me an error that qemu didn't recognize the -avd flag. So the emulator binary must pass the -avd flag to qemu. It seems like Google's builds of qemu are highly customized if they're taking an android virtual device flag, so a local build would be more trouble than it's worth (I only need Android Studio to complete one school project). So I will probably resize my primary partition and add a dual boot to Ubuntu or Windows 10, then reclaim the space when I'm finished with the class. Other than the emulator, Android Studio seems to work just fine under Gentoo.
Back to top
View user's profile Send private message
perlovka
n00b
n00b


Joined: 04 Aug 2004
Posts: 16
Location: Israel

PostPosted: Wed Aug 23, 2017 7:00 pm    Post subject: Reply with quote

I managed to run it as following (I have android-sdk-update-manager and apulse installed, user is in android group):

Code:
$ cd /opt/android-sdk-update-manager/emulator
$ apulse ./emulator -avd Nexus_10_API_23
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum