如何在装有Apple Silicon的Mac上通过命令行启动Android模拟器?

问题描述 投票:0回答:1

问题

尝试通过命令行启动 Android 模拟器时出现以下错误:

Could not launch '~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory

复制步骤

  1. 使用配备 Apple Silicon 的 Mac。
  2. 已设置模拟器,例如 Android 14 上的 Pixel 8(API 级别 34)。
  3. 运行命令以模拟器名称启动模拟器,例如:
    ~/Library/Android/sdk/tools/emulator @Pixel_8_API_34

目前为止的调查

可能原因

该错误似乎正在发生,因为模拟器二进制文件的正确位置是:

~/Library/Android/sdk/emulator/qemu/darwin-aarch64/qemu-system-aarch64

不正确位置比较:

~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64

信息来自
-verbose

使用

-verbose
运行会提供以下信息:

emulator:Android emulator version 26.0.3.0 (build_id 3965150)
emulator:Found AVD name 'Pixel_8_API_34'
emulator:Found AVD target architecture: arm64
emulator:argv[0]: '~/Library/Android/sdk/tools/emulator'; program directory: '~/Library/Android/sdk/tools'
emulator:Auto-config: -engine qemu2 (arm64 default)
emulator:  Found directory: ~/Library/Android/sdk/system-images/android-34/google_apis_playstore/arm64-v8a/

emulator:try dir ~/Library/Android/sdk/tools
emulator:try dir ~/Library/Android/sdk/tools/
emulator:try dir ~/Library/Android/sdk/emulator
emulator:Found target-specific 64-bit emulator binary: ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_swiftshader'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle9'
emulator:Adding library search path: '~/Library/Android/sdk/emulator/lib64/gles_angle11'
emulator: Adding library search path for Qt: '~/Library/Android/sdk/emulator/lib64/qt/lib'
emulator: Setting Qt plugin search path: QT_QPA_PLATFORM_PLUGIN_PATH=~/Library/Android/sdk/emulator/lib64/qt/plugins
emulator: Running :~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64
emulator: qemu backend: argv[00] = "~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64"
emulator: qemu backend: argv[01] = "@Pixel_8_API_34"
emulator: qemu backend: argv[02] = "-verbose"
emulator: Concatenated backend parameters:
 ~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64 @Pixel_8_API_34 -verbose
Could not launch '~/Library/Android/sdk/emulator/qemu/darwin-x86_64/qemu-system-aarch64': No such file or directory

来自文档的信息

我已经查看了用于在命令行上启动 Android 模拟器的 documentation,但不确定是否有选项。

android android-emulator android-sdk-tools
1个回答
0
投票

为了避免架构不匹配,请确保您已经安装了基于 ARM 的模拟器。您可以在 Android Studio -> AVD Manager -> 创建虚拟设备中执行此操作。 现在,在“系统映像”选项卡中,选择“ARM 映像”。从列表中选择包含系统映像 ARM 64 v8a 的映像。 安装完成后,返回终端并导航至 Android/sdk/emulator/

然后运行以下命令列出可用的 AVD

./emulator -list-avds

后面是您用来运行它的命令

./emulator -avd Your_AVD_Name

© www.soinside.com 2019 - 2024. All rights reserved.