I’m trying to use Android Studio, but the virtual android doesn’t start because of KVM error. Tinkering around with another VM application I understood that it’s a location/permission issue (flatpak Gnome Boxes had the same issue, couldn’t load KVM, but Boxes installed via terminal worked and I could start a VM).

On the official Android Studio website they suggest extracting the tar.zip in /usr/local but the system doesn’t allow me to, so I extacted it on the desktop and the app runs, but I get a “/dev/kvm is not found” error, which should be because of the location I’m running Android Studio from.

So, should I just sudo force move the folder of Android Studio from desktop to /usr/local or is there a better way to do it?

PoP_OS just in case it can be useful to know.

Thanks in advance!

  • @mumeiOP
    link
    2
    edit-2
    1 day ago

    Thanks for the reply and the testing. It’s not via Flatpak (I figured it would be best not to, since Flatpak Gnome Boxes could not create a VM because of KVM issues, while Boxes installed via sudo apt install gnome-boxes gave me no error), but a simple tar extracted in desktop.

    Since AMD Virtualization is Enabled in BIOS (although I can’t toggle it) and Gnome Boxes can create a VM when installed via terminal, I don’t think it’s a BIOS or CPU problem (otherwise no version of Boxes would allow me to run a VM, but I did launch Arch btw from inside Boxes).

    Am I wrong?

    Thanks!

    • @[email protected]
      link
      fedilink
      English
      3
      edit-2
      1 day ago

      Based on using a local installation without elevated permissions (outside of /usr/(local)), I can only guess of two things happening:

      The first is GNOME Boxes asks for elevated permissions when running or otherwise uses Polkit to gain those permissions. Your user by default likely isn’t granted access to /dev/kvm and running userland software without additional permissions will inherently not allow KVM access.

      To allow this sanely, you can add your user to the KVM group to allow userland KVM access. It can be done via sudo adduser "<username>" kvm and then restarting your computer. To note, this is something that can allow any application to access virtualization without special permissions. If you don’t want this change to remain forever, the command sudo usermod -r -G kvm "<username>" followed by a restart can revert this change.

      Alternatively, installing Android Studio via the Flathub Flatpak may handle permissions without needing to modify user groups in this case.

      The second (unlikely, but possible) problem is the AppArmor profile blocking KVM access for userland. I don’t have particularly any experience with creating modified profiles for AppArmor, if this is the cause. I could only offer terrible advice for AppArmor (disabling AppArmor or switching to warn-only, both things I do not recommend doing). Again, it might be worth trying to install Android Studio via flatpak to see if things work better if this is the cause.

      • @mumeiOP
        link
        11 day ago

        I get the same exact error via Flatpak and “the user … is already a member of kvm”, unfortunately.

        Thanks anyway!

        • @[email protected]
          link
          fedilink
          English
          21 day ago

          I did accidentally type the relevant command incorrectly, forgetting that sudo swaps the user before subcommands like whoami will resolve. So that command attempted to add the kvm group to ‘root’ rather to your user. I have fixed the command in the relevant comment for anyone else reading this thread. You can try sudo adduser "<username>" kvm, manually substituting <username> for your username. As normal, restart after adding the group to your user. Additionally, I have added a warning to the solution in the original comment of why you may not want to keep this solution enabled forever as well as a way to disable it later if desired.

          • @mumeiOP
            link
            1
            edit-2
            1 day ago

            Oh, yeah, I got an error with the original command you wrote, so I ended up typing the correct one anyway, and that’s what returned the message that I’m already part of that group.

            So, just to make it clear, sudo adduser “<myusername>” kvm was the command I ended up using and that told me I’m already part of the group (I’ve been trying basically all solutions I could find online and I think one suggestion was to add myself to the group, so I may have already issued that command earlier today and I did restart several times between then and now)

      • @mumeiOP
        link
        11 day ago

        Thanks a lot, appreciated. I think I’ll try Flatpak Android Studio first, and move on to the suggestion of adding myself to the KVM group in case Flatpak install doesn’t fix the issue. Thanks again!