Open Dolfik1 opened 7 months ago
I found out that the crash is related to the headless mode. It can be reproduced as follows:
nix develop -c avdmanager create avd -n test -k 'system-images;android-33;google_atd;x86_64'
Then, if you try to launch the created emulator in headless mode:
nix develop -c emulator -avd test -no-window -verbose
You'll encounter the following error:
qemu: could not load PC BIOS 'bios-256k.bin'
libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
[59201:119788773:20240415,113627.963893:WARNING crash_report_exception_handler.cc:235] UniversalExceptionRaise: (os/kern) failure (5)
However, if you omit the -no-window parameter:
nix develop -c emulator -avd test -verbose
everything will start successfully without errors.
After a detailed examination of the issue, I found that the problem was at the strip stage. I resolved this issue as follows (by dontStrip flag):
system = if system == "aarch64-darwin" then "x86_64-darwin" else system;
overlays = [
(self: super: {
androidsdk = android.sdk.${system} (sdkPkgs: with sdkPkgs; [
build-tools-33-0-0
cmdline-tools-latest
(emulator.overrideAttrs (_: { dontStrip = isDarwin64; }))
Ideally, this requires further investigation into the reasons for such behavior, but this solution can be used as a hotfix.
Encountered an issue with gradle managed devices on MacOS x86. A sample project demonstrating the problem can be found here.
Reproduction Steps:
To replicate the issue, execute the following command:
nix develop -c ./test.sh
This command executes successfully on a Mac M2 but fails on a Mac Pro x86, resulting in the following Gradle error:
The full log file is attached to this issue. Here is some key highlights:
Within the logs, a command used to run qemu:
Troubleshooting Attempts
While unsure about the appropriateness of manually invoking this command (because Gradle can add some stuff to env), it was attempted. However, the following error was encountered:
Upon investigation, libemugl_common.dylib was found at the following location:
/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/lib
As a workaround, the directory containing libemugl_common.dylib was added to the DYLD_LIBRARY_PATH environment variable using the following script:
export DYLD_LIBRARY_PATH="/nix/store/a9h0g1pmp2hsyqkv23v0q3s40dhrr5rs-emulator-35.1.2/lib:$DYLD_LIBRARY_PATH"
This action resolved the previous error, but resulted in a new message: