Running the android emulator from the command line

So the android emulator works fine through android-studio, but it’s a bit annoying to have to open android-studio every time I want to launch the emulator so I want to open it from the CLI, but for some reason running the emulator command gives this error

Failed to execute process '/home/skykanin/Android/Sdk/emulator/emulator'. Reason:
The file '/home/skykanin/Android/Sdk/emulator/emulator' does not exist or could not be executed.

So I looked around on the forums and nixpkgs manual and found this Nixpkgs 23.11 manual | Nix & NixOS. So I wrote this nix file to run an android emulator

with import <nixpkgs> {};

androidenv.emulateApp {
  name = "Pixel_4_API_29";
  platformVersion = "29";
  abiVersion = "x86";
  enableGPU = true;
  avdHomeDir = "/home/skykanin/.android/avd";
  systemImageType = "google_apis";
}

created an AVD instance that matched the android sdk version of my emu.nix file (29) through android studio and ran nix-build emu.nix && ./result/bin/run-test-emulator, but I get this error

Looking for a free TCP port in range 5554-5584
We have a free TCP port: 5554
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
	at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
	at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
	at com.android.sdklib.tool.AvdManagerCli.run(AvdManagerCli.java:213)
	at com.android.sdklib.tool.AvdManagerCli.main(AvdManagerCli.java:200)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
	... 5 more

So I’m not sure exactly how one can run the emulator from the command line

Any news on that @skykanin ? I’m having the same issue

No, I was never able to get this working and just resorted to opening android studio every time I wanted the AVD manager