Android Studio emulator not working

I am running nixos-unstable NixOS 20.03pre194293.2436c275.
When trying to launch an emulator from Android Studio, I get the following error:

Emulator: /home/julius/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64:
error while loading shared libraries: cannot open shared object file: No such file or directory
Emulator: Process finished with exit code 127

I have tried running Pixel 3 API 29 and Nexus 5X API 28, both produce the same error.

I have also tried running an emulator with emulateApp (app attribute is set to the apk file built by Android Studio):

with import <nixpkgs> {
  config = {
    android_sdk.accept_license = true;

androidenv.emulateApp {
  name = "PolarView";
  platformVersion = "28";
  abiVersion = "x86_64";
  systemImageType = "default";
  app = app/build/outputs/apk/debug/app-debug.apk;
  package = "com.github.jul1u5.polarview";
  activity = ".MainActivity";

After getting a dated looking emulator by executing result/bin/run-test-emulator I get this error:

adb: failed to install /nix/store/323pqyjip2k4ipz3bxyz9884wz1vbw2l-app-debug.apk:
Failure [INSTALL_FAILED_TEST_ONLY: installPackageLI]

The emulator also has an enormous unnecessary keyboard on the right side, and I can’t find how to get rid of it.

I have also tried using buildApp for the app attribute however, the derivation fails to build because:

Buildfile: build.xml does not exist!
Build failed

I have no idea what build.xml is, and where it should come from (Android Studio doesn’t create this file).

I would appreciate if someone could explain any of my questions:

  1. Why I can’t run emulators from Android Studio and how can I fix this?
  2. How can I get emulateApp and buildApp functions to work?
  3. How can I update or modify (disable the onscreen keyboard) the emulator that is produced by emulateApp?

Unfortunately newer versions of the emulator required additional dependencies that we hadn’t added yet.

This should now be fixed on master but it might take a few days for it to land in the channels:

Good to hear, that it has been fixed! How can I track when the fix will be available on the unstable channel?

Also, are there any good up to date references/examples of how to use emulateApp and buildApp? I have looked at reflex-platform repository but it’s quite complex.

I just checked and it’s already in the nixos-unstable channel.

There seems to be an official documentation:

If those examples don’t work it might be a good idea to open an issue.

There are also a few older blog posts, but I’m not sure if they’re still that helpful:

But as I never used emulateApp myself, I unfortunately cannot help you with this :o