NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.7k stars 13.84k forks source link

Android Studio can't run emulators #214817

Closed yswtrue closed 1 year ago

yswtrue commented 1 year ago

Describe the bug

Android Studio can't run emulators, display: Not enough memory to run HAXM

Steps To Reproduce

Steps to reproduce the behavior:

  1. install android-studio in environment.systemPackages
  2. run android-studio
  3. create an emulator
  4. run the emulator
  5. display Not enough memory to run HAXM

Expected behavior

Emulator can run

Screenshots

image

Additional context

Notify maintainers

@alapshin

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 ~/C/nixos-config   *~  nix-shell -p nix-info --run "nix-info -m"                                                                                                                       
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.9-zen1, NixOS, 23.05 (Stoat), 23.05.20230204.0591d6b`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.2`
 - channels(root): `"home-manager, nixos-22.11"`
 - nixpkgs: `/nix/store/n14283gcxp1l2qj0h53lngw4rl4y9xkd-source`
dotlambda commented 1 year ago

How is this related to Nixpkgs?

yswtrue commented 1 year ago

But I still have many memory

 ~/Code  free -h                                                                                                                                                                          
               total        used        free      shared  buff/cache   available
内存:       61Gi        35Gi       2.5Gi       3.4Gi        23Gi        22Gi
交换:       67Gi       170Mi        67Gi
yswtrue commented 1 year ago

Maybe it is because of missing some dependences. I have enable libvirtd and installed bridge-utils

kirillrdy commented 1 year ago

@yswtrue sadly error from android studio is missleading

this happens when android studio cant access kvm device, this has happened to me in the past when i was using systemd.enableUnifiedCgroupHierarchy = true

so I'd start by checking you permissions to /dev/kvm and see if in your configuration nothing else is using kvm device

if /dev/kvm device is missing check for intel_kvm or amd_kvm kernel modules ( depending on your hardware )

yswtrue commented 1 year ago

I have also set systemd.enableUnifiedCgroupHierarchy = false and there is /dev/kvm and my user is in kvm group. image

and I can run emulator in Virtual Machine Manager image

but in android-studio there is no kvm group image

kirillrdy commented 1 year ago

@yswtrue can you provide your configuration ? otherwise I would suggest remove most of things from your configuration,.

something basic like this

environment.systemPackages = with pkgs; [ android-studio ] ;

works for me, as in, I can run emulator

 nix-info -m
 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.10, NixOS, 23.05 (Stoat), 23.05.20230210.9943fcc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.13.2`
 - channels(root): `"nixos-22.05"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
yswtrue commented 1 year ago

I have disable waydroid and libvirtd, and android-studio emulator works for me now, but I can't running android-studio emulator and virtualbox emulator at tie same time. Thank you very much. @kirillrdy

kirillrdy commented 1 year ago

closing as resolved, feel free to reopen

alkeryn commented 1 year ago

@kirillrdy i cannot disable libvirt, and android studio doesn't work because of that issue.

edit: i could fix it with systemd.enableUnifiedCgroupHierarchy = lib.mkForce true;