Improve reliability of StopAvd with try-catch logic

Open
#64 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
android, csharp

Research direction

Start in AndroidSdk/Emulator/Emulator.cs and inspect the StopAvd polling loop, especially its calls to adb.GetDevices(). Review how SdkToolFailedExitException is handled elsewhere, then verify that shutdown failures do not escape the method and that StopAvd still returns a boolean by the timeout.

Written by the indexing model from the issue text.

Description

The 'StopAvd' method in 'AndroidSdk/Emulator/Emulator.cs' polls 'adb.GetDevices()' during shutdown, but 'GetDevices()' can throw 'SdkToolFailedExitException' if adb exits with a non-zero status.

As identified in PR #63 review (https://github.com/Redth/AndroidSdk.Tools/pull/63#discussion_r2818506593), this can cause 'StopAvd' to throw an exception instead of returning a boolean as expected.

To improve reliability, especially in CI environments where adb might be flaky during shutdown sequences, this method should:

  1. Wrap the polling loop in a try-catch block.
  2. Catch 'SdkToolFailedExitException' (and possibly others).
  3. Treat failures as 'still running' (or retry) until the timeout is reached.

This ensures the method adheres to its contract of returning true/false rather than crashing.

Dominant language
C#
Stars
78
Forks
18
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Redth/AndroidSdk.Tools

All issues in Redth/AndroidSdk.Tools

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.