我需要从 Linux 终端运行模拟器。我已经在我的 Ubuntu VM 上安装了 Android Studio,创建了设备并成功运行它。我也从 android studio 的终端运行它。但是当我尝试从 Linux 终端运行它时,我得到了这个输出:
root@mobyleapp2:~/Android/Sdk/emulator# sudo ./emulator -avd Pixel_6_API_34
INFO | Android emulator version 32.1.14.0 (build_id 10330179) (CL:N/A)
INFO | Found systemPath /root/Android/Sdk/system-images/android-34/google_apis/x86_64/
INFO | Storing crashdata in: /tmp/android-root/emu-crash.db, detection is enabled
INFO | Duplicate loglines will be removed, if you wish to see each indiviudal line launch with the -log-nofilter flag.
Authorization required, but no authorization protocol specified
Authorization required, but no authorization protocol specified
INFO | Warning: could not connect to display :0.0 ((null):0, (null))
INFO | Info: Could not load the Qt platform plugin "xcb" in "/root/Android/Sdk/emulator/lib64/qt/plugins" even though it was found. ((null):0, (null))
Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
((null):0, (null))
INFO | Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Available platform plugins are: xcb.
((null):0, (null))
[76827:76827:20230824,104224.778525:ERROR elf_dynamic_array_reader.h:64] tag not found
[76827:76827:20230824,104224.778609:ERROR elf_dynamic_array_reader.h:64] tag not found
[76827:76827:20230824,104224.783132:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq: No such file or directory (2)
[76827:76827:20230824,104224.783153:ERROR file_io_posix.cc:144] open /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq: No such file or directory (2)
Aborted
两个终端都使用 /bin/bash shell 和相同的环境变量。 例如我的变量:
PATH=/root/Android/Sdk/emulator:/root/Android/Sdk/cmdline-tools:/root/Android/Sdk/build-tools:/root/Android/Sdk/platform-tools:/root/Android/Sdk/emulator:/root/Android/Sdk/tools:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/root/Android/Sdk/platform-tools/
LD_LIBRARY_PATH = /usr/lib/x86_64-linux-gnu/qt5/plugins/
ANDROID_SDK_ROOT = /root/Android/Sdk/
ANDROID_HOME = /root/Android/Sdk/
JAVA_HOME=/opt/android-studio/jbr/
DISPLAY=:0.0
我使用相同的用户 root 和相同的启动命令:
sudo ./emulator -avd Nexus_5X_API_34
我的android studio路径:
/opt/android-studio/
我开始工作室:来自我的默认用户“steam”的sudo ./opt/android-studio/bin/studio.sh
。
不知怎的,我无法从根用户运行它。
SDK路径:/root/Android/Sdk
android studio 版本:长颈鹿 | 2022年3月1日
我只需要从其他用户启动模拟器,因为 root 用户禁用图形。