Anyone successfully do Android development on Qubes?

I have Android Studio up and running without any issues. The problem is debugging the code on a device. I’ve tried to spin up an emulator but it never launched (kept loading and loading). Tried to connect to my physical device via WiFi but couldn’t get it to work either. When I tried pairing with QR code, my device wasn’t connecting with the adb server. When I tried pairing with pairing code, adb said it successfully connect but couldn’t see the device with “adb devices”.

I tried connecting my phone to the computer via USB and then attached the phone to the VM running Android studio but Android Studio didn’t detect the device.

Has anyone successfully done Android development on Qubes? If so, how do you do it?

I had recent success with a physical device, HVM qube, and USB connection. adb devices showed the device straight away but as unauthorized so I had to start adb as root outside Android Studio. PVH also seems to work fine. I find debugging adb problems frustrating - it always seems like everyone has a solution that doesn’t work for anyone else’s device/computer.
(ETA: this is with an Android 8 device that can only do USB connections.)

No success with the built-in emulator even with a PV qube and I don’t know nearly enough about the low level details on nested virtualization to go poking around, but when I looked on this forum I got the impression it was blocked. There are a few Waydroid threads if that’s an option for you.

Have you tried something like this?

Note that a more elegant solution would be to create a second sys-usb with android tools and use it only for Android debugging.

How did you create your HVM qube?

I tried creating a second sys-usb but when I switch over from the first to second I can’t use my keyboard/mouse. How do you do the switchover?

You need to configure your USB keyboard/mouse policies for your second sys-usb qube in Qubes OS Global Config → USB Devices tab.

Switch HVM on in the qube settings - Advanced tab, under Virtualization. I don’t think it makes a difference here, though.

That makes sense, I see that now. Thanks!

Got it, I’ll try these suggestions out and post back.

A bit more progress with the emulator here.

  1. HVM qube with Android Studio installed and some avd
  2. Alter /usr/share/qubes/templates/libvirt/xen.xml in dom0, setting <feature name='vmx' policy='require' /> (different systems may use smx instead of vmx)
  3. Restart libvirtd in dom0
  4. Verify the avd starts from the HVM qube command line with emulator -avd <AVD> Do this from the command line because Android Studio hides errors.

It wasn’t working for me before because I had a disk space issue on the HVM qube. This was reported when I ran the emulator from the command line. It will also report if you haven’t got vmx/smx enabled.

At this point, the emulator starts up and gives a warning about nested virtualization (may not work at all, expect bad performance).

Boot time (Pixel 3a) was 3 minutes.

Then, running from Android Studio and deploying a hello world app, I had something weird going on with the emulator screen going blank, but that went away and it basically worked. It wasn’t quite as slow as I was expecting, so maybe it’s usable - not sure yet.

I’m not saying it’s a good or safe idea to enable nested virtualization, just that it works. You can find threads with more details by searching this forum for nested virtualization or android.

I switched from HVM to PVH after this and it still works, looks a lot faster, and doesn’t run as hot.