Skip to content

fix(emulator): detect Android devices when only adb is installed - #37128

Merged
AmoabaKelvin merged 2 commits into
mainfrom
android-adb-only-32126
Nov 1, 2026
Merged

AmoabaKelvin merged 2 commits into
mainfrom
android-adb-only-32126

Conversation

@AmoabaKelvin

@AmoabaKelvin AmoabaKelvin commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​65 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​55
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​58 $\color{#cf222e}{\Huge{\mathbf{−}}}$​42 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​16

ELI5

If you only installed adb (for example from your Linux distro's android-tools package or Homebrew) and not Android Studio's emulator, Orca didn't see your phone at all, even though adb devices listed it. Now it does.

What Changed

Before: the Mobile Emulator device list was empty and showed "No emulator devices found" on any host without the SDK emulator package, and a standalone adb on PATH was never looked at.

After: USB devices show up as long as Orca can find adb. AVDs still appear and boot when the emulator package is installed. Without it, only running devices are listed, and attaching a stopped AVD by name fails with the usual "not a running device or a known AVD" error instead of starting a missing binary.

How it works:

  • discoverAndroidSdk needs only adb. It still prefers an SDK root that also has emulator (same pick as before for full SDKs), then an SDK root with platform-tools only, then adb on PATH through the shared resolveExecutableCommand.
  • AndroidSdkPaths.emulator and sdkRoot can be null. listAvdNames skips emulator -list-avds when there's no emulator, and AVD boot refuses before launching.
  • Settings shows the adb path under "Detected at" when there's no SDK root.
  • Dropped the unused avdmanager path and updated the Android emulator skill guide's prerequisites.

Why

Root cause: android-sdk-discovery.ts returned a result only when an SDK root had both adb and emulator. Every Android feature depends on that result, so hosts with only adb lost physical devices, which never needed the emulator binary.

Supersedes #9950 only for the SDK discovery part. That PR adds ADB network connections across 52 files, has merge conflicts, and makes the emulator optional without adding the PATH lookup this issue needs. This PR is the small change that fixes the root cause on its own, and it credits the shared idea with Co-authored-by.

Linked Issue

Fixes #32126

Visual Proof

N/A. The Settings screens are unchanged; the difference is whether a device appears. CLI evidence from a real macOS host with no SDK root, using HOME=<empty dir>, PATH=/opt/homebrew/bin:/usr/bin:/bin, and a running emulator visible to Homebrew adb:

  • main: discoverAndroidSdkFromHost() returns null, so no devices.
  • this branch: { sdkRoot: null, adb: '/opt/homebrew/bin/adb', emulator: null }, and listAndroidDevices returns the booted emulator-5554.
  • with the real full SDK at ~/Library/Android/sdk: the same root as before, with the running device and shutdown AVDs listed.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

On macOS I ran discovery and the device list against real adb, before and after, as described above. The discovery tests cover an adb-only SDK root, a full SDK preferred over an earlier adb-only root, and the PATH fallback. An inventory test checks that only adb runs on an adb-only host. All src/main/emulator tests pass (33 files). Changed-file oxlint, oxfmt, a scoped typecheck, and verify:bundled-skill-guides / verify:skill-bundle-manifest pass. Not tested on a real Linux or Windows host. Paths use path.join, and the PATH lookup uses the shared resolver, which handles adb.exe and ; on Windows.

AI Disclosure

Review

review-loop round 1 was clean: Codex had no findings, and Claude raised three P3s that I left as is. One is an SDK root that has emulator but no adb while adb comes from PATH. It's rare, and it didn't work before either. The other two are the copy of the stopped-AVD error and the Settings label showing the adb path.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • Remote/SSH and orca serve: discovery runs on the host that runs the runtime, same as before. AndroidSdkPaths never goes over RPC, so clients and hosts on different versions are unaffected.
  • Performance: discovery still runs once per availability check or command. On hosts with no adb, the PATH scan adds a few synchronous stat calls. It doesn't run on a polling path.
  • Mobile and folder workspaces: no change.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

SDK discovery required both adb and the emulator binary under an SDK
root, so hosts with platform-tools only, or a standalone adb such as a
distro android-tools package, saw no Android devices at all. Discovery
now needs only adb, falls back to adb on PATH, and AVD listing and boot
are skipped when the emulator package is missing.

Fixes #32126

Co-authored-by: s546126 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e73276c5-c08e-4e65-9e0e-86b99b1af695
Commits

Reviewing files that changed from the base of the PR and between 45c7556 and d46ef11.

Files selected for processing: 1
  • src/main/emulator/android/android-device-inventory.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

Walkthrough

Android SDK discovery now accepts ADB from an SDK root or from PATH, even when the emulator binary is absent. Device inventory can list connected devices in that configuration and returns no AVD names without the emulator binary. AVD boot validation uses the shared AVD-name listing helper. The Android emulator guide and bundled guide describe these requirements.

Severity of issue fixed: Medium

Merge Risk: Moderate · up to d46ef

Some Android hosts may fail to detect connected devices despite having a working adb on PATH; the fallback should be corrected before merging.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: detecting Android devices when only adb is installed.
Description check Passed The description is complete and directly matches the changes. It includes the user impact, implementation details, rationale, linked issue, visual-proof explanation, testing results, review notes, com…
Linked Issues check Passed Issue #32126 is the only active directly linked issue. The reviewed head accepts an SDK root that contains adb without emulator, prefers a full SDK when available, and falls back to adb resolved…
Out of Scope Changes check Passed The changed production files support issue #32126. They implement adb-only discovery, PATH resolution, device inventory without the emulator binary, safe AVD handling, and the detected adb path. Fixtu…
Full details: Description check

Explanation

The description is complete and directly matches the changes. It includes the user impact, implementation details, rationale, linked issue, visual-proof explanation, testing results, review notes, compatibility considerations, and checklist status.

Full details: Linked Issues check

Explanation

Issue #32126 is the only active directly linked issue. The reviewed head accepts an SDK root that contains adb without emulator, prefers a full SDK when available, and falls back to adb resolved from PATH. listAndroidDevices runs with adb-only paths, while AVD listing skips the missing emulator. Tests cover adb-only discovery, full-SDK preference, PATH fallback, and device inventory. The reported final commit only removes a test type assertion, so it does not remove these requirements.

Full details: Out of Scope Changes check

Explanation

The changed production files support issue #32126. They implement adb-only discovery, PATH resolution, device inventory without the emulator binary, safe AVD handling, and the detected adb path. Fixture updates and documentation updates support the implementation. Removing the unused avdmanager path follows the updated SDK path model. No unrelated change is established. The incremental diff was unavailable, but the supplied whole-PR summary and current-head evidence identify no unrelated change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 6 functions across 13 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to GitHub limitations.

⚠️ Outside diff range comments (1)

Minor · Update the missing-ADB guidance. · orca-emulator-android.md:47-48

skill-guides/orca-emulator-android.md:47-48
Minor · Functional Correctness · Quick win

Update the missing-ADB guidance.

When no SDK-root ADB or PATH ADB is found, the guide and androidSdkMissing still tell users to install Android Studio and set ANDROID_HOME. A standalone ADB now satisfies the prerequisite. Tell users to install ADB or configure an SDK path, and update the runtime message as well as the guide. (raw.githubusercontent.com)


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a3db7a1a-2361-488d-aa26-1818ae3ce5ce
Commits

Reviewing files that changed from the base of the PR and between 9f416bb and 45c7556.

Files selected for processing: 14
  • skill-guides/orca-emulator-android.md
  • src/cli/bundled-skill-guides.ts
  • src/main/emulator/android/android-avd-boot-identity.test.ts
  • src/main/emulator/android/android-avd-boot.ts
  • src/main/emulator/android/android-capability-operations.test.ts
  • src/main/emulator/android/android-device-inventory.test.ts
  • src/main/emulator/android/android-device-inventory.ts
  • src/main/emulator/android/android-input-commands.test.ts
  • src/main/emulator/android/android-sdk-discovery.test.ts
  • src/main/emulator/android/android-sdk-discovery.ts
  • src/main/emulator/android/android-sdk-host-discovery.ts
  • src/main/emulator/android/scrcpy-stream-session.test.ts
  • src/main/emulator/backends/android-emulator-backend.test.ts
  • src/main/emulator/backends/android-emulator-backend.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.

}
const rootsWithAdb = candidateSdkRoots(env, platform, homedir)
.map((sdkRoot) => resolveToolPaths(sdkRoot, win32))
.filter((paths) => exists(paths.adb))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor · Functional Correctness · Quick win

Require a runnable SDK-root ADB before selecting it.

If platform-tools/adb exists but is not executable, this filter selects it and skips a runnable adb on PATH. Host discovery supplies existsSync, while the PATH resolver checks whether its result is runnable. The selected ADB then cannot list the connected device. Check SDK-root ADB candidates for executability before applying the documented fallback. (raw.githubusercontent.com)

@AmoabaKelvin
AmoabaKelvin merged commit 5ea047e into main Nov 1, 2026
46 checks passed
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…blyai#37128)

* fix(emulator): detect Android devices with only adb installed

SDK discovery required both adb and the emulator binary under an SDK
root, so hosts with platform-tools only, or a standalone adb such as a
distro android-tools package, saw no Android devices at all. Discovery
now needs only adb, falls back to adb on PATH, and AVD listing and boot
are skipped when the emulator package is missing.

Fixes stablyai#32126

Co-authored-by: s546126 <[email protected]>

* test(emulator): drop type assertion in adb-only inventory test

---------

Co-authored-by: s546126 <[email protected]>
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…blyai#37128)

* fix(emulator): detect Android devices with only adb installed

SDK discovery required both adb and the emulator binary under an SDK
root, so hosts with platform-tools only, or a standalone adb such as a
distro android-tools package, saw no Android devices at all. Discovery
now needs only adb, falls back to adb on PATH, and AVD listing and boot
are skipped when the emulator package is missing.

Fixes stablyai#32126

Co-authored-by: s546126 <[email protected]>

* test(emulator): drop type assertion in adb-only inventory test

---------

Co-authored-by: s546126 <[email protected]>
Nenzyz pushed a commit to Nenzyz/orca that referenced this pull request Nov 2, 2026
…blyai#37128)

* fix(emulator): detect Android devices with only adb installed

SDK discovery required both adb and the emulator binary under an SDK
root, so hosts with platform-tools only, or a standalone adb such as a
distro android-tools package, saw no Android devices at all. Discovery
now needs only adb, falls back to adb on PATH, and AVD listing and boot
are skipped when the emulator package is missing.

Fixes stablyai#32126

Co-authored-by: s546126 <[email protected]>

* test(emulator): drop type assertion in adb-only inventory test

---------

Co-authored-by: s546126 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Android physical device detection fails without AVD emulator installed (missing system PATH adb discovery)

1 participant