Fails to parse ADB output because of \r
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- android, typescript
- 领域
- mobile-dev
调研方向
从 src/android/utils/adb.ts 大约第 362-366 行开始,在 WSL 下复现 adb devices 的问题,其中输出行包含回车符。跟踪这些行的解析方式,并验证已连接的设备会被识别,而不是被报告为不可用。
由索引模型根据 Issue 内容生成。
描述
Version:
1.4.0
Description:
Trying to run yarn ionic cordova run android --livereload --device leads to the error below. I'm running the command on WSL, adb and yarn are installed on WSL.
$ which yarn && which adb
/usr/bin/yarn
/opt/android/platform-tools/adb
Command Output:
Command ran :
yarn native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --device --forward 8100:8100 --verbose
Output :
yarn run v1.22.18
$ /path-to-project/node_modules/.bin/native-run android --app platforms/android/app/build/outputs/apk/debug/app-debug.apk --device --forward 8100:8100 --verbose
native-run:android:utils:sdk:resolveSDKRoot Looking for $ANDROID_HOME +0ms
native-run:android:utils:sdk:resolveSDKRoot Using $ANDROID_HOME at /opt/android +3ms
native-run:android:utils:sdk:resolveEmulatorHome Looking for $ANDROID_EMULATOR_HOME +0ms
native-run:android:utils:sdk:resolveEmulatorHome Looking at $HOME/.android +0ms
native-run:android:utils:sdk:resolveEmulatorHome Using $HOME/.android/ at /home/mbenoukaiss/.android +1ms
native-run:android:utils:sdk:resolveAVDHome Looking for $ANDROID_AVD_HOME +0ms
native-run:android:utils:sdk:resolveAVDHome Looking at $HOME/.android/avd +0ms
native-run:android:utils:sdk:resolveAVDHome Using $HOME/.android/avd/ at /home/mbenoukaiss/.android/avd +1ms
native-run:android:utils:adb:getDevices Invoking adb with args: [ 'devices', '-l' ] +0ms
native-run:android:utils:sdk:getSDKPackage Parsing /opt/android/platform-tools/package.xml +0ms
native-run:android:utils:adb:parseAdbDevices Parsing adb devices from output lines: [
native-run:android:utils:adb:parseAdbDevices 'List of devices attached\r',
native-run:android:utils:adb:parseAdbDevices '22005523027480 device product:TC21MG model:TC21 device:TC21 transport_id:1\r',
native-run:android:utils:adb:parseAdbDevices '\r',
native-run:android:utils:adb:parseAdbDevices ''
native-run:android:utils:adb:parseAdbDevices ] +0ms
native-run:android:utils:adb:parseAdbDevices adb devices output line does not match expected regex: '22005523027480 device product:TC21MG model:TC21 device:TC21 transport_id:1\r' +0ms
native-run:android:utils:adb:parseAdbDevices adb devices output line does not match expected regex: '\r' +0ms
native-run:android:utils:adb:getDevices Found adb devices: [] +82ms
native-run:android:utils:avd:getAVDINIs Discovered AVD ini files: [
native-run:android:utils:avd:getAVDINIs '/home/mbenoukaiss/.android/avd/Pixel_3_API_30.ini',
native-run:android:utils:avd:getAVDINIs '/home/mbenoukaiss/.android/avd/Pixel_3_API_31.ini'
native-run:android:utils:avd:getAVDINIs ] +0ms
native-run Caught fatal error: AndroidRunException [Error]: No hardware devices found. Not attempting emulator because --device was specified.
native-run at selectDevice (/path-to-project/node_modules/native-run/dist/android/run.js:83:19)
native-run at async Object.run (/path-to-project/node_modules/native-run/dist/android/run.js:32:20)
native-run at async Object.run (/path-to-project/node_modules/native-run/dist/android/index.js:19:5)
native-run at async Object.run (/path-to-project/node_modules/native-run/dist/index.js:20:13) {
native-run code: 'ERR_NO_DEVICE',
native-run exitCode: 1,
native-run data: undefined
native-run } +0ms
ERR_NO_DEVICE: No hardware devices found. Not attempting emulator because --device was specified.
More details for this error may be available online:
https://github.com/ionic-team/native-run/wiki/Android-Errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Adding/changing the lines from 232 to 235 in the file adb.js in the screenshot below fixes the problem, idk if it's the best way to fix it though :

Link to the concerned line in the project : https://github.com/ionic-team/native-run/blob/develop/src/android/utils/adb.ts#L362:L366
SDK Info:
SDK Location: /opt/android
AVD Home: /home/mbenoukaiss/.android/avd
API Level: 31
Packages: Android SDK Platform 31 platforms;android-31 1
Intel x86 Atom_64 System Image system-images;android-31;default;x86_64 3
API Level: 30
Packages: Android SDK Platform 30 platforms;android-30 3
Google Play Intel x86 Atom System Image system-images;android-30;google_apis_playstore;x86 9
API Level: 29
Packages: Android SDK Platform 29 platforms;android-29 5
Google Play Intel x86 Atom System Image system-images;android-29;google_apis_playstore;x86 8
Tools:
Android Emulator emulator 31.2.9
Android SDK Build-Tools 30.0.3 build-tools;30.0.3 30.0.3
Android SDK Platform-Tools platform-tools 33.0.1
Android SDK Tools tools 26.1.1
SDK Patch Applier v4 patcher;v4 1
- 主要语言
- TypeScript
- 星标
- 141
- 派生
- 35
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ionic-team/native-run 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
ionic-team/native-run#409 ·
-
难度 3/5 1-2 天 新手友好度 66/100
ionic-team/native-run#410 · 1 条评论 ·
-
tools not found?未关闭android
难度 4/5 3-5 天 新手友好度 25/100
ionic-team/native-run#395 ·
-
android
难度 3/5 1-2 天 新手友好度 28/100
ionic-team/native-run#390 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 38/100
ionic-team/native-run#389 ·
查看 ionic-team/native-run 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
-
难度 2/5 1-3 小时 新手友好度 73/100
hugomrdias/playwright-test#753 ·
维护者通常 1 天内回复
-
Review view: Daily/Weekly Review header buttons use the app-wide toolbar control style可能已有人在做 @colherdesopa 今天认领。 未关闭
难度 1/5 1-3 小时 新手友好度 90/100
dongdongbh/Mindwtr#1515 ·
维护者通常 1 天内回复
-
pending-triage
难度 2/5 1-3 小时 新手友好度 70/100
kirodotdev/Kiro#12301 ·
-
难度 2/5 1-3 小时 新手友好度 83/100