Repository navigation
Android emulator system image picker - #2843
moondial-pal wants to merge 38 commits into
Conversation
|
The approach was revised during the PyCon sprint after a discussion with @mhsmith. |
… and no system image.
…rmed versions in list_available_system_images
…e across platforms
|
Are the 3 CI failures pre-existing or am I goofing something here?
I checked recent CI runs on main and found some of these issues crop up there. |
|
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. |
| for line in output.splitlines(): | ||
| package = line.split("|")[0].strip() | ||
| if not package.startswith("system-images"): | ||
| continue |
There was a problem hiding this comment.
The code above this point could be replaced with a call to list_installed_system_images.
There was a problem hiding this comment.
Sorry, not replaced exactly, but the duplicate code should be factored out.
There was a problem hiding this comment.
The duplication with list_installed_system_images is still unresolved.
|
Thanks for the detailed feedback. I'll work through each point. |
The bottom of the list looks fine to me, since they are the newest versions.
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.
The ideal solution is probably to make it default to |
|
Sounds good on all three. |
…_api_level logic with gradle.py
|
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. |
mhsmith
left a comment
There was a problem hiding this comment.
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. |
…, dedent error, unused variable, API level fallback
|
Apologies for the delayed submission. |
|
@moondial-pal Looks like you've hit a pre-commit problem... |
# Conflicts: # src/briefcase/integrations/android_sdk.py # tests/integrations/android_sdk/AndroidSDK/test_create_emulator.py
|
Dropping a not that I am working on the fixes. Should have something submitted for review soon. |
|
Thanks, and FYI, we're planning a Briefcase release on Tuesday, so if you can update the PR by Monday, I'll make sure to merge it in time for that. No problem if it takes longer, though. |
|
Finally got something submitted, ready for review. |
freakboy3742
left a comment
There was a problem hiding this comment.
Thanks - I've taken this for a spin, and it worked well; but I think there's some tweaks needed in the specific workflow to make it more useful for common use cases. Details inline.
| def _parse_system_image(package: str): | ||
| """Parse a system image package identifier into its components. | ||
|
|
||
| :param package: e.g. ``"system-images;android-31;default;x86_64"`` |
There was a problem hiding this comment.
Markdown only requires a single backtick.
| :param package: e.g. ``"system-images;android-31;default;x86_64"`` | |
| :param package: e.g. `"system-images;android-31;default;x86_64"` |
| """Sort key for API level strings, ordering numeric levels (and their ext suffixes) | ||
| numerically. Non-numeric levels sort after all numeric ones. | ||
|
|
||
| e.g. "android-34" -> (0, 34.0, 0) "android-34-ext9" -> (0, 34.0, 9) |
There was a problem hiding this comment.
packaging.Version is a better representation here than a Float.
There was a problem hiding this comment.
Specifically, float will work fine for any of the existing versions, but it will break if the minor version ever gets into 2 digits, because 34.10 would be equal to 34.1.
There was a problem hiding this comment.
packaging.Version is overkill for this; replaced with a tuple of ints.
|
|
||
| # TODO: Provide a list of options for system images. | ||
| system_image = self.DEFAULT_SYSTEM_IMAGE | ||
| # Get available images, raise an error if none found. |
There was a problem hiding this comment.
These questions need to come before we select an emulator name - otherwise the user will select beePhone-31 as their image name, and then select an SDK 34 image.
This likely also means modifying the DEFAULT_AVD property so it's more of a "generate a good base AVD for this set of device properties" method (which, for now, is just the API level - but it could be modified in future to take the device type into account, once we add skin selection)
| # TODO: Provide a list of options for system images. | ||
| system_image = self.DEFAULT_SYSTEM_IMAGE | ||
| # Get available images, raise an error if none found. | ||
| available_images = self.list_available_system_images( |
There was a problem hiding this comment.
This query takes a bit of time, which makes it look like nothing is happening. We should wrap this in a transient wait_bar so the user knows what is happening while they wait.
| default=( | ||
| self.DEFAULT_IMAGE_TYPE | ||
| if self.DEFAULT_IMAGE_TYPE in image_types | ||
| else image_types[0] |
There was a problem hiding this comment.
I think it would be better to present "no default", rather than pick one at random. In my testing, I tried using "android-36.1", and it defaulted to "android-wear-signed" as the image type, which won't be a good match.
There was a problem hiding this comment.
I think a better preference order would be:
defaultgoogle_apis– comes with some closed-source Google apps.google_apis_ps16k– same asgoogle_apisbut uses 16 KB pages. This and the correspondingplaystoreimage are the only ones available on the very newest API levels.- If none of those are available, then no default. This doesn't happen for any API level that currently exists, but it can be covered by the unit tests.
| # Parse available images once for use in both selection questions. | ||
| parsed_images = [_parse_system_image(img) for img in available_images] | ||
|
|
||
| # Ask the user to select an API level. |
There was a problem hiding this comment.
This approach works, but I think it might need some refinement to be most useful, especially to non-expert users.
At present, by default, the user is faced with 34 options for android SDK, many of which are highly esoteric - e.g., "android-36-ext15". This is entirely correct, but not especially helpful for a non-expert user. Even though there's a good default, 35 options is a little overwhelming; and if you accept the default, you're then faced with the image type question, which I'm not sure even I fully understand :-)
My suggestion would be:
- Show an initial list of images that have been filtered to a "provides a
defaultsystem image type", and also provide a "non-default image types" menu option. This means the user will see "android-24, android-25,... android-37.0, non-default system images" as their list of options - 15 total, and a very "vanilla" list . - If they select one of the images, use it in a "default" image type configuration.
- If they select "non-default image types":
- show a sorted list of image types that are available -
google_apis,google_apis_playstore,aosp_atd, ... - Show a list of API levels that are filtered to that image type
- show a sorted list of image types that are available -
That should make the solve 90% of use cases with an approachable list, while still providing flexibility for the remainder of uses.
Does that make sense?
There was a problem hiding this comment.
Since #3033 a default device is automatically created and used unless the -d argument is passed, so anyone who gets into this menu is already asking for somewhat advanced behavior.
However, I agree that it's a bit overwhelming, and too easy for the user to get stuck, e.g. if they pick android-34-ext9, then their only image type option will be android-automotive, which is unlikely to be useful.
As I mentioned in my previous comment, I suspect Google is in the process of phasing out default, so we can't privilege it too much. Instead, how about only showing the "vanilla" versions, i.e. those whose name is a dotted sequence of numbers with no additional text? This is roughly what the Android Studio emulator creation dialog does by default. Anyone who really needs one of the other versions should be expert enough to create the emulator themselves outside of Briefcase. I've never needed any of them myself.
In that case, we would keep the image type question, but give it a more intelligent default as in my previous comment.
|
Fixed all outstanding comments, but not ready to merge yet because emulators with dots in their version all fail to boot. |
As usual, they didn't give any useful error messages whatsoever, but I eventually worked out that we needed to update the command-line tools. |
|
|
||
| ### Android SDK | ||
|
|
||
| If you have an existing install of the Android SDK, it will be used by Briefcase if the `ANDROID_HOME` environment variable is set. If `ANDROID_HOME` is not present in the environment, Briefcase will honor the deprecated `ANDROID_SDK_ROOT` environment variable. Additionally, an existing SDK install must have version 19.0 of Command-line Tools installed; this version can be installed in the SDK Manager in Android Studio. |
There was a problem hiding this comment.
Briefcase installs the required Command-line Tools version automatically, just like it does all other SDK packages. So I've replaced the specific version with a more general statement.

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:
Assisted-by: Claude Sonnet 4.6