How do you run Android Studio on NixOS without errors

I’m just getting getting started in Android development and installed JetBrains-ToolBox from the nixos-unstable and got AS (Android Studio) from there. Proceeded with trying out some very basic “Views” in AS, and after a couple days I cannot emulate the app for the life of me. I’ve tried almost every advice from Stackoverflow (except maybe running the emulator from cmdline which I couldn’t do). I tried reinstalling AS, Toolbox, the SDK, making new VDs. Nothing worked. Still getting error running app the emulator process for avd has terminated.

How do you successfully run Android Studio on NixOS?

1 Like

Here is the stack trace around the emulator failure:

INFO - #com.android.tools.idea.run.AndroidDeviceSpec - Creating spec for privacy sandbox enabled device.
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - /home/ari/Android/Sdk/emulator/emulator -netdelay none -netspeed full -avd Pixel_3a_API_34_extension_level_7_x86_64 -qt-hide-window -grpc-use-token -idle-grpc-timeout 300
INFO - #com.android.tools.idea.gradle.project.build.invoker.GradleBuildInvoker - About to execute Gradle tasks: [:app:assembleDebug]
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - Storing crashdata in: /tmp/android-ari/emu-crash-35.1.4.db, detection is enabled for process: 84115
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - Android emulator version 35.1.4.0 (build_id 11672324) (CL:N/A)
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - Found systemPath /home/ari/Android/Sdk/system-images/android-34/google_apis/x86_64/
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - /home/ari/Android/Sdk/emulator/qemu/linux-x86_64/qemu-system-x86_64: error while loading shared libraries: libpng16.so.16: cannot open shared object file: No such file or directory
INFO - Emulator: Pixel_3a_API_34_extension_level_7_x86_64 - Process finished with exit code 127

I recommend you to use nixpkgs for IDEs. Or at least Flatpaks.
Maybe you can try installing libpng.

I’ve now separately installed it from stable and unstable nixpkgs from within my flakes setup. Only change is that now I can’t find new emulator crash logs :laughing:. Same error though. I’ll have to keep looking into it.