无法从命令行启动Android模拟器

时间:2018-06-15 19:39:27

标签: android nixos

奇怪的是我可以从android-studio启动同样的avd - 但是当我尝试从命令行启动它时,我得到了这个:

$ DISPLAY=":0" emulator @28
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  55
  Current serial number in output stream:  54
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  GLXBadContext
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  6 (X_GLXIsDirect)
  Serial number of failed request:  55
  Current serial number in output stream:  54
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: i965_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: i965
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  155 (GLX)
  Minor opcode of failed request:  24 (X_GLXCreateNewContext)
  Value in failed request:  0x0
  Serial number of failed request:  39
  Current serial number in output stream:  40
QObject::~QObject: Timers cannot be stopped from another thread

我只在这台PC上安装了AS,因为您似乎无法通过CLI设置AVD。这应该成为另一个构建服务器 - 真的不知道那里发生了什么。在ubuntu上没有问题 - 但我正在尝试使用nixos设置另一个构建服务器。

1 个答案:

答案 0 :(得分:0)

Android-studio使用FHSUserEnv,启动模拟器时可能需要相同的环境

% nix-shell -p android-studio
[nix-shell:~/git/nixpkgs]$ which android-studio
[nix-shell:~/git/nixpkgs]$ cat /nix/store/a2vs86rhf2a9va1792i87h3pmir6y7v5-android-studio-3.1.3.0/bin/android-studio
#!/nix/store/dkh7l9a4sx7zqh8riqbj3z21sz25p8xy-bash-4.4-p23/bin/bash
/nix/store/cpiignabpci7p7dqir3bx6gs4mcghcg7-android-studio-fhs-env/bin/android-studio-fhs-env /nix/store/fnls4fjf5cd5za87l83ja9ibcqnkpy90-android-studio-3.1.3.0/bin/studio.sh
[nix-shell:~/git/nixpkgs]$ /nix/store/cpiignabpci7p7dqir3bx6gs4mcghcg7-android-studio-fhs-env/bin/android-studio-fhs-env

还要确保opengl驱动程序在LD_LIBRARY_PATH中(nixos上的默认设置)。

[joerg@turingmachine nixpkgs]$ echo $LD_LIBRARY_PATH
/run/opengl-driver/lib:/run/opengl-driver-32/lib:/usr/lib:/usr/lib32
[joerg@turingmachine nixpkgs]$ # try starting the emulator here