Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 815307 - dev-util/android-studio: Emulator unable to run
Summary: dev-util/android-studio: Emulator unable to run
Status: UNCONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Jason A. Donenfeld
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-29 06:46 UTC by Casey Avila
Modified: 2022-12-21 12:24 UTC (History)
8 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Casey Avila 2021-09-29 06:46:27 UTC
Upon trying to run the android emulator in the AVD installed with android-studio, an error is prompted stating "Not enough memory to run HAXM." My computer, with 16 gigabytes of memory is most definitely enough to run the android emulator, and I had successfully ran it before the icedtea-bin package was updated to 3.16.0.


Some notes:
Prior to icedtea-bin 3.16.0, the emulator would start successfully with icedtea-bin (yet the error would occur with openjdk-bin). Because of this, I don't think it's actually an issue of memory quantity, along with the fact that HAXM isn't used on Linux because there is KVM. Also, the fact that it worked with icedtea-bin and not openjdk-bin leads me to believe this is a packaging issue.
Comment 1 Casey Avila 2021-09-29 06:46:54 UTC
Portage 3.0.20 (python 3.9.6-final-0, default/linux/amd64/17.1/hardened, gcc-10.3.0, glibc-2.33-r1, 5.10.61-gentoo x86_64)
=================================================================
System uname: Linux-5.10.61-gentoo-x86_64-AMD_Ryzen_5_1600X_Six-Core_Processor-with-glibc2.33
KiB Mem:    16406164 total,   2615236 free
KiB Swap:    8388604 total,   8372988 free
Timestamp of repository gentoo: Wed, 29 Sep 2021 05:30:01 +0000
Head commit of repository gentoo: 4538454589d0f37545ec378638d54b07f1c3c59b
Timestamp of repository brother-overlay: Sun, 19 Sep 2021 21:51:57 +0000
Head commit of repository brother-overlay: 09ee0c1e201a47821384e215b1f4e60daa6c2e9c

Timestamp of repository guru: Mon, 27 Sep 2021 17:07:23 +0000
Head commit of repository guru: 3e1bf76cfe853b1acb661c93620fceea17cd20e9

Timestamp of repository ricerlay: Mon, 27 Sep 2021 17:07:22 +0000
Head commit of repository ricerlay: dbfc527161bcb7d503549ed8db4c0530dac57e9f

sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0-r2::gentoo
dev-lang/python:          3.9.6_p2::gentoo
dev-lang/rust:            1.53.0::gentoo
dev-util/cmake:           3.20.5::gentoo
sys-apps/baselayout:      2.7::gentoo
sys-apps/openrc:          0.43.5::gentoo
sys-apps/sandbox:         2.24::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.69-r5::gentoo
sys-devel/automake:       1.16.4::gentoo
sys-devel/binutils:       2.37_p1::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.10::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r1::gentoo
Repositories:

gentoo
    location: /var/db/repos/gentoo
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    sync-rsync-verify-max-age: 24
    sync-rsync-verify-jobs: 1
    sync-rsync-extra-opts: 
    sync-rsync-verify-metamanifest: yes

brother-overlay
    location: /var/db/repos/brother-overlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/brother-overlay.git
    masters: gentoo

guru
    location: /var/db/repos/guru
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/guru.git
    masters: gentoo

kc
    location: /var/db/repos/kc
    masters: gentoo

ricerlay
    location: /var/db/repos/ricerlay
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/ricerlay.git
    masters: gentoo

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-march=native -O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-march=native -O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="es_MX.utf8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j12"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="X acl alsa amd64 bluetooth bzip2 crypt elogind hardened iconv ipv6 libglvnd libtirpc multilib ncurses nls nptl openmp pam pcre pie pulseaudio readline seccomp split-usr ssl ssp unicode vdpau vulkan xattr xtpax zlib" ABI_X86="64" ADA_TARGET="gnat_2019" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx avx2 f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="nvidia" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LC_ALL, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 2 Tee KOBAYASHI 2021-09-29 22:50:03 UTC
I wonder if this can be worked around by launching emulator directly and not via AVD Manager:

$ /opt/android-sdk-update-manager/emulator && ./emulator -avd foo
Comment 3 Tee KOBAYASHI 2021-09-30 00:04:25 UTC
A typo in my previous comment. I meant

$ cd /opt/android-sdk-update-manager/emulator && ./emulator -avd foo
Comment 4 Casey Avila 2021-09-30 09:01:26 UTC
Oh yes I forgot to mention. Launching the emulator directly works perfectly fine, which was another reason why I thought this might be a packaging bug.

The only minor difference is that my emulator binary is located in `~/Android/Sdk/emulator/` rather than the path you provided.
Comment 5 deim 2021-10-01 10:59:59 UTC
I can confirm the error.
I can also run emulator directly.
AVD manager says in Troubleshoot: "Get more available memory for HAXM".
I have 32GB RAM.
Comment 6 Adam Giergun 2021-10-04 18:51:37 UTC
It seems to be something wrong with AMD Ryzen processor recognition. HAXM is Intel proprietary, completely not usable with AMD processors.

BTW current version of android-studio needs Java 11. Looks like Icedtea 3.16.0 is still based on OpenJDK 8. Have you tried openjdk-bin-11?
Comment 7 deim 2021-10-05 06:19:17 UTC
I have Intel CPU but under Linux it should use KVM.
AFAIK latest Android Studio has JDK 11 included.
In SDK's emulator dir there is emulator-check:

$ ./emulator-check accel
accel:
0
KVM (version 12) is installed and usable.

$ ./emulator-check cpu-info
cpu-info:
146
Intel CPU|Virtualization is supported|64-bit CPU|
Comment 8 Casey Avila 2021-10-12 06:50:21 UTC
As for running with JDK 11, how would we do that? As far as I know the highest version of a system vm you can install on Gentoo is JDK 8.
Comment 9 Adam Giergun 2021-10-16 11:00:38 UTC
(In reply to Casey Avila from comment #8)
> As for running with JDK 11, how would we do that? As far as I know the
> highest version of a system vm you can install on Gentoo is JDK 8.

You are mixing up two things, virtual/jdk (where 11 is still masked), and system-vm, which one can set via eselect. In the latter case it's possible to emerge openjdk (or openjdk-bin) 11, using gentoo-vm switch, and use it as system-vm.
Comment 10 Petric Frank 2021-11-29 09:19:24 UTC
Fresh install on a machine with Intel 6700T CPU. Using openjdk-bin-8*. VT is enabled in BIOS and kvm-intel kernel module is loaded. Checks shown in comment #7 executed successfully.

Using AVD manager it even don't let me configure a VM. At the step to select a VM image it shows the message "Not enough memory for HAXM" for every possible image. The "Next" button is grayed out so i can not complete the AVD configuration.

Copied a AVD from an other machine with an older android studio installation to ~/.android. AVD manager shows this VM but still not allow to start it due to HAXM problem.

From command line executed "~/Android/Sdk/emulator/emulator -avd <avd-name>" starts the AVD successfully.

So i can confirm this bug.

If this is relevant - installed also openjdk-bin-11* but "eselect java-vm list" does not list it as option.
Comment 11 Christophe PEREZ 2021-12-19 15:18:41 UTC
(In reply to Petric Frank from comment #10)
> Fresh install on a machine with Intel 6700T CPU. Using openjdk-bin-8*. VT is
> enabled in BIOS and kvm-intel kernel module is loaded. Checks shown in
> comment #7 executed successfully.
> 
> Using AVD manager it even don't let me configure a VM. At the step to select
> a VM image it shows the message "Not enough memory for HAXM" for every
> possible image. The "Next" button is grayed out so i can not complete the
> AVD configuration.
> 
> Copied a AVD from an other machine with an older android studio installation
> to ~/.android. AVD manager shows this VM but still not allow to start it due
> to HAXM problem.
> 
> From command line executed "~/Android/Sdk/emulator/emulator -avd <avd-name>"
> starts the AVD successfully.
> 
> So i can confirm this bug.

Same for me.

> If this is relevant - installed also openjdk-bin-11* but "eselect java-vm
> list" does not list it as option.

But you can use it though, but configuring your project to.
File > Project structure > SDK Location > Gradle settings > Gradle JDK > Add JDK > select /opt/openjdk-bin-11
Comment 12 Petric Frank 2022-02-16 07:33:01 UTC
On Reddit i found a solution:
  https://www.reddit.com/r/Gentoo/comments/ma60iv/help_i_dont_what_this_means_but_its_not_working/gweloyu/

In the last entry it was explained that openjdk is the problem. Install icedtea-bin and select it as system-vm cures the problem.

Verified - it works for me.

It seems openjdk has a problem here.
Comment 13 Petric Frank 2022-02-17 06:57:11 UTC
Spoke too early.

The change of the java-vm to icedtea cures (or work around) the problem for version 4.1.3.0.201.7199119 only.
The current (unstable) version 2020.3.1.24 in portage tree.

So there must be something between version 4.1.3.0.201.7199119 and 2020.3.1.24 triggering this HAXM message.
Comment 14 Adam Giergun 2022-05-05 13:10:24 UTC
Petric:
Have you checked it for example with Android Studio 2021.1.1.23?
It's available here: https://github.com/AdamGiergun/adasss
Comment 15 Petric Frank 2022-05-31 14:38:13 UTC
(In reply to Adam Giergun from comment #14)
> Petric:
> Have you checked it for example with Android Studio 2021.1.1.23?
> It's available here: https://github.com/AdamGiergun/adasss

Adam:

sorry for the delay. From the adass repository i took the following ebuild:
  android-studio-2021.2.1.15.ebuild

Still not able to create/start VM from GUI. Applies to android-studio-2021.2.1.15.ebuild also.

The only difference now is that it let me configure a VM, but i am still not able to start it (HAXM error).
Comment 16 Adam Giergun 2022-05-31 19:28:25 UTC
Petric:
As I understand in your case icedtea (or openjdk) is used to run Android Studio?

Try to create in 
    /etc/env.d 
file
    99android-studio
with content
    STUDIO_JDK="/opt/android-studio/jre/"
and then just reboot.
After that Android Studio should run on built-in JDK regardless of that from system, so then check emulator.

Also, from what I understand, icedtea 3.21.0 is still based on Java 8. Recent Android Studio should be run on Java 11.
Comment 17 Petric Frank 2022-06-03 10:51:10 UTC
(In reply to Adam Giergun from comment #16)
> Petric:
> As I understand in your case icedtea (or openjdk) is used to run Android
> Studio?
> 
> Try to create in 
>     /etc/env.d 
> file
>     99android-studio
> with content
>     STUDIO_JDK="/opt/android-studio/jre/"
> and then just reboot.
> After that Android Studio should run on built-in JDK regardless of that from
> system, so then check emulator.
> 
> Also, from what I understand, icedtea 3.21.0 is still based on Java 8.
> Recent Android Studio should be run on Java 11.

I've removed icedtea-8 and installed openjdk-11 (-bin).

Added the env-variable and rebooted. Checked STUDIO_JDK environment variable is set.

No change (android-studio 2021.2.1 Patch 1). Message "Could not start AVD.
When editing the AVD the "HAXM"-Box is still there.
Comment 18 Adam Giergun 2022-06-03 12:41:03 UTC
(In reply to Petric Frank from comment #17)
> 
> I've removed icedtea-8 and installed openjdk-11 (-bin).
> 
> Added the env-variable and rebooted. Checked STUDIO_JDK environment variable
> is set.
> 
> No change (android-studio 2021.2.1 Patch 1). Message "Could not start AVD.
> When editing the AVD the "HAXM"-Box is still there.

Openjdk could be removed too. Android Studio could be run without any system JDK.
You could also check beta or canary version of Android Studio from my repo, it will be installed side by side with the stable one. It will also allow to install some beta version of Emulator (I'm using Android Emulator 31.3.8 presently).
Comment 19 Igor Franchuk 2022-11-13 06:17:56 UTC
Same problem with 4.1.2 - couldn't start emulator from studio, worked well from the command line, icetea solution fixed 4.1.2 too

after install go to : /opt/android-studio/bin/studio.sh

and add: 

# ---------------------------------------------------------------------
# Locate a JDK installation directory which will be used to run the IDE.
# Try (in order): STUDIO_JDK, studio.jdk, ./jre64, JDK_HOME, JAVA_HOME, "java" in PATH.
# ---------------------------------------------------------------------
STUDIO_JDK="/opt/icedtea-bin-3.16.0/"
Comment 20 deim 2022-11-15 08:16:18 UTC
I looked for solution months back and found solution on my main PC somehow but I can't recall what I changed. Emulator runs fine - no HAXM message at all. But I tried to install on my another PC and It gives me the HAXM error message.

I tried to change [home]/.config/Google/AndroidStudio2021.3/studio64.vmoptions:
-Xms512m
-Xmx16g

But no luck. I had to change some settings somewhere else.

I'll share solution once I get clue about it. Don't you have a tip where to look? What to compare? /opt/android-studio of my main PC and the another one are the same.
Comment 21 Jonas Jelten 2022-12-08 22:17:38 UTC
Just as a sidenote (since i found this as the google result for not being able to run the emulator properly, since it was lagging like crazy and using much IO load), this is what I needed to do to make the emulator work flawlessly on btrfs:

echo "QuickbootFileBacked = off" >> ~/.android/advancedFeatures.ini

see https://issuetracker.google.com/issues/117641628#comment12

Apart from that, running the emulator from dev-util/android-studio works (with the bundled jre).
Comment 22 Reva Denis 2022-12-21 12:24:21 UTC
I've discovered that android emulator does not support OpenGL hardware acceleration with XWayland at all. It gives no error, just black screen. And since it lack of native wayland support, you should use swiftshader.