Android: running emulator classified as hardware when adb device name is not generic*, so --virtual fails with ERR_NO_TARGET

未关闭 适合新手
#409 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
android, typescript
领域
mobile-dev

调研方向

从 dist/android/utils/adb.js 中的 parseAdbDevices 开始,issue 指出了用于分类 ADB 设备的 device: 名称检查。根据报告的 emulator-5554 属性验证行为,并检查 Android 设备列表测试。完成标准是:已连接的 emulator-<port> 即使设备名称为 emu64xa16k,也会列为虚拟设备,并且可以通过 --virtual 选择。

由索引模型根据 Issue 内容生成。

描述

Version: native-run 2.0.3 (latest on npm)

Platform: Linux x86_64, Android Emulator 37.1.11, AVD from the Pixel 10 profile with a 16 KB page-size system image (sdk_gphone16k_x86_64, API 37)

Description

A running emulator is classified as hardware, so --virtual cannot select it and run fails with ERR_NO_TARGET, even though adb lists the emulator as connected.

adb devices -l reports:

emulator-5554  device product:sdk_gphone16k_x86_64 model:sdk_gphone16k_x86_64 device:emu64xa16k transport_id:1

dist/android/utils/adb.js (parseAdbDevices) only treats a serial as an emulator when its device: property starts with generic:

const isGenericDevice = (properties['device'] || '').startsWith('generic');
const type = 'usb' in properties || isIP || !serial.startsWith('emulator') || !isGenericDevice ? 'hardware' : 'emulator';

Current emulator system images report device:emu64xa16k (and similar emu64* values), not generic*. The emulator therefore becomes type: 'hardware'.

Steps to reproduce

  1. Start an AVD whose system image reports a non-generic device name, e.g. a recent Google APIs / 16 KB page-size image.
  2. native-run android --list --json lists it under devices, and virtualDevices stays empty.
  3. native-run android --app app-debug.apk --virtual fails:
ERR_NO_TARGET: No target devices/emulators available.

The same command without --virtual installs on the emulator, because it is picked as a hardware device.

ionic cordova run android --emulator maps to --virtual, so Ionic Cordova live reload on an emulator is affected.

Expected

A serial of the form emulator-<port> that adb reports in the device state is a running emulator, whatever its device: property says. --virtual should select it.

Possible fix

Classify emulator-<port> serials as emulators without depending on the device: name, or additionally accept the emu* prefix. Alternatively, check ro.kernel.qemu / ro.boot.qemu from getprop, which getDevices already reads.

Related

#324: AVD home resolution ignores $ANDROID_USER_HOME/XDG locations. In the same setup that compounds this bug, because the fallback that would boot an AVD finds none.

主要语言
TypeScript
星标
139
派生
35
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/native-run 的其他 Issue

查看 ionic-team/native-run 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。