Skip to content

Android sys img picker#2843

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

Android sys img picker#2843
moondial-pal wants to merge 21 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
Comment thread src/briefcase/integrations/android_sdk.py Outdated
system_image = self.DEFAULT_SYSTEM_IMAGE
# Get available images, raise an error if none found.
available_images = self.list_available_system_images(
min_version=getattr(app, "min_os_version", ANDROID_MIN_OS_VERSION)

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.

Recommend factoring out this getattr expression into a function, and using it in output_format_template_context. That would eliminate any risk of the two locations going out of sync.

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.

Also, although min_os_version is used as an integer in the Gradle template, Briefcase documents it as a string, for consistency with the other platforms. This will probably lead to a TypeError when it's compared to an integer in list_available_system_images. There should be a test to make sure we accept both types.

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
skin = self.DEFAULT_DEVICE_SKIN

# TODO: Provide a list of options for system images.
system_image = self.DEFAULT_SYSTEM_IMAGE

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.

DEFAULT_SYSTEM_IMAGE is still used in one other place, but it should be updated to make sure it's consistent with the default Android version and image type used in this function. This would probably involve creating DEFAULT properties for those two things, and using them in both locations.


# Create a mock app
app = MagicMock()
del app.min_os_version # ensure getattr fallback is used

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.

There should be at least one test of the attribute being present.

@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.

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