Skip to content

Android sys img picker - #2843

Open
moondial-pal wants to merge 23 commits into
beeware:mainfrom
moondial-pal:android-sys-img-picker
Open

Android sys img picker#2843
moondial-pal wants to merge 23 commits into
beeware:mainfrom
moondial-pal:android-sys-img-picker

Conversation

@moondial-pal

Copy link
Copy Markdown
Contributor

Added two step selection flow that fetches all available compatible images from sdkmanager --list.
Hard coded version is set if default is selected.

This enables the user to select an android version when creating a new emulator.

Fixes #737

PR Checklist:

  • I will abide by the BeeWare Code of Conduct
  • I have read and have followed the CONTRIBUTING.md file
  • This PR was generated or assisted using an AI tool

Assisted-by: Claude Sonnet 4.6

@moondial-pal

Copy link
Copy Markdown
Contributor Author

The approach was revised during the PyCon sprint after a discussion with @mhsmith.
Am going to work on aligning tests and see if I can nail this down.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Are the 3 CI failures pre-existing or am I goofing something here?

  • docs-lint broken https://www.x.org/ link in x11passthrough.md, not touched by my PR
  • Windows ARM PySide6 build, similar failure visible in recent main branch CI runs
  • ReadTheDocs appears to be an infrastructure build failure?

I checked recent CI runs on main and found some of these issues crop up there.
I'm not sure how to get them to pass at this point 😅

@moondial-pal
moondial-pal marked this pull request as ready for review May 23, 2026 16:36
@mhsmith

mhsmith commented May 25, 2026

Copy link
Copy Markdown
Member

Yes, the failures aren't related to this PR, so you don't need to worry about them.

Thanks for the updates, I'll look at this in a couple of days.

@mhsmith
mhsmith self-requested a review May 25, 2026 13:40
Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py Outdated
for line in output.splitlines():
package = line.split("|")[0].strip()
if not package.startswith("system-images"):
continue

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The code above this point could be replaced with a call to list_installed_system_images.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry, not replaced exactly, but the duplicate code should be factored out.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The duplication with list_installed_system_images is still unresolved.

Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py Outdated
Comment thread src/briefcase/integrations/android_sdk.py
Comment thread tests/integrations/android_sdk/AndroidSDK/test__create_emulator.py
@moondial-pal

Copy link
Copy Markdown
Contributor Author

Thanks for the detailed feedback. I'll work through each point.
The suggestion to factor out the parsing logic and treat versions independently makes a lot of sense. I'll get back to you with updates.

@moondial-pal

moondial-pal commented Jun 18, 2026

Copy link
Copy Markdown
Contributor Author

Digging into the API level sorting here is the current state of the API level selection wizard for feedback:

image

I had some questions before going any further.

  1. android-CANARY and android-CinnamonBun have no numeric component, so currently they sort to the bottom of the list alphabetically rather than near a numeric position.
    CinnamonBun is the codename for the 37 preview.
    CANARY is a rolling pre-release with no fixed API level.
    How would we want to sort those?

  2. android-37.0 and android-CinnamonBun both appear to refer to the same underlying release.
    Should these be de-duplicated or is showing both acceptable?

  3. The API level prompt currently defaults to 31.
    Do we want to stick with that or have the wizard default to the latest?

That brings up another question that may be out of scope for this pr but how do we want to handle default API level selection as the years progress?

@mhsmith

mhsmith commented Jun 18, 2026

Copy link
Copy Markdown
Member
  1. android-CANARY and android-CinnamonBun have no numeric component, so currently they sort to the bottom of the list alphabetically rather than near a numeric position.
    CinnamonBun is the codename for the 37 preview.
    CANARY is a rolling pre-release with no fixed API level.
    How would we want to sort those?

The bottom of the list looks fine to me, since they are the newest versions.

  1. android-37.0 and android-CinnamonBun both appear to refer to the same underlying release.
    Should these be de-duplicated or is showing both acceptable?

If they have separate SDK packages, then let's show them separately. At some point, I think the package with the codename will disappear, but existing emulators should continue to work.

  1. The API level prompt currently defaults to 31.
    Do we want to stick with that or have the wizard default to the latest?

That brings up another question that may be out of scope for this pr but how do we want to handle default API level selection as the years progress?

The ideal solution is probably to make it default to target_os_version. But you don't have to do that in this PR unless you want to; sticking with the current default is fine.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Sounds good on all three.
Keeping current sort order for numeric and named entries.
The default will remain android-31 for now, will tackle target_os_version in a separate PR.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Still working on this. I have been on a camping/road trip for the past 9 days and won't return until 7/6/26 😅. I should be able to submit something that week.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

After hitting an issue with a default selection for the tag, it comes to mind that a similar edge case could occur if android-31 isn't available for the user's architecture. Honestly not sure how likely that is, but the API level prompt will crash since DEFAULT_API_LEVEL won't be in the options list. Essentially, the tag prompt had the same issue and I fixed it with self.DEFAULT_TAG if self.DEFAULT_TAG in tags else tags[0]. Should I apply a similar pattern for the API level default, or would you prefer a different fallback?

@mhsmith

mhsmith commented Jul 8, 2026

Copy link
Copy Markdown
Member

ARM64 and x86_64 are our only supported architectures for the build machine, and we know they are both available for the current hard-coded default API level. So I don't think we need to worry about that now.

@mhsmith

mhsmith commented Jul 10, 2026

Copy link
Copy Markdown
Member

Hi, I saw your comment on the community call, so I'll look at this as soon as I can. In future, you can post a comment on a PR to let us know it's ready for another review.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Hi, I saw your comment on the community call, so I'll look at this as soon as I can. In future, you can post a comment on a PR to let us know it's ready for another review.

I was on the fence on if that would be a nuisance or not. Only because I know that yourself and Russell have your work cut out for you as far as reviews go. Anytime I have submitted a PR both of you have always reviewed within a very reasonable time.
I learn a little bit more about the contributing norms with each PR, so thanks for mentioning that.
Absolutely. Moving forward I'll make sure to communicate when I have something ready for review.

Honestly because I was on that long trip, I hadn't been able to work on submitting anything until 2 days before the meeting. I had nothing else to post or talk about so I thought I would at least update the progress of this PR 😅

@moondial-pal

Copy link
Copy Markdown
Contributor Author

I believe I have addressed all the feedback. Ready for review.

@freakboy3742

Copy link
Copy Markdown
Member

@moondial-pal Apologies for the delay in reviewing this - we should be able to get to this in the next couple of days.

@mhsmith mhsmith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for taking so long. This is looking pretty good now, just a few more comments, plus one unresolved conversation from the previous round.

Comment on lines +1264 to +1266
tag = self.tools.console.selection_question(
intro="Select the system image tag:",
description="Tag",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is there any precedent for calling this a "tag"? "Type" seems like a more obvious name, and has previously been used in Android Studio (see right side of screenshot).


# Ask the user to select an API level.
api_levels = sorted(
{api_level for api_level, _, abi in parsed_images},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
{api_level for api_level, _, abi in parsed_images},
{api_level for api_level, _, _ in parsed_images},

Comment on lines +778 to +781
"""Returns a sorted list of system image package identifiers available for the
current architecture and minimum Android version.

e.g., ``{"system-images;android-31;default;x86_64"}``

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The sorting seems redundant, since they'll be sorted again in the one place that calls this function. In which case, maybe it could return a set instead, which would be more consistent with list_installed_system_images, and would make the docstring example syntax correct.

Comment on lines +1234 to +1236
raise BriefcaseCommandError(
f"""\
No Android system images are available for your architecture

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This could use the same dedent function as your other PR.

Comment on lines +1239 to +1240
This may be caused by a network connectivity issue or an unsupported
architecture. Check your network connection and re-run `briefcase run android`.

@mhsmith mhsmith Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Network connectivity seems like an unlikely cause, because if the sdkmanager failed to contact the server, it should have caused a CalledProcessError. However, it would be worth mentioning min_os_version and its value, since that's the other thing used for filtering here. There's no guarantee that CANARY will continue to exist, so setting min_os_version to a very high number could return no results.

intro="Select the API level for the emulator:",
description="API level",
options=api_levels,
default=self.DEFAULT_API_LEVEL,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If min_os_version is set high enough, this may not be a valid default. There should be a fallback to default to the first item, like in the other question below.

intro="Select the system image tag:",
description="Tag",
options=tags,
default=self.DEFAULT_TAG if self.DEFAULT_TAG in tags else tags[0],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't look like this tags[0] fallback is unit tested.

@moondial-pal

Copy link
Copy Markdown
Contributor Author

Sorry for taking so long. This is looking pretty good now, just a few more comments, plus one unresolved conversation from the previous round.

Not an issue at all, I know this issue has been a bit drawn out.
I'll work on the feedback, thanks.

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.

Improve flexibility of Android emulator system image

3 participants