Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump Android Command-line Tools from 6.0 to 9.0 #1397

Merged
merged 4 commits into from
Aug 8, 2023

Conversation

rmartin16
Copy link
Member

@rmartin16 rmartin16 commented Aug 1, 2023

Changes

  • The version of the Android Command-line Tools is bumped from 6.0 to 9.0
  • Previously, Android's Command-line Tools were installed into cmdline-tools/latest by Briefcase.
  • However, the SDK supports a versioned layout for installed packages. To take advantage of this, the Command-line Tools are now installed in to cmdline-tools/9.0 in the Briefcase data directory.
  • This also ensures that user SDKs are providing the same version of Command-line Tools as Briefcase installs.
  • If an externally managed SDK doesn't have Command-line Tools version 9.0, it will be installed in to the SDK using the latest version of Command-line Tools.
    • If latest version isn't installed, the user is warned and the Briefcase-managed SDK is used.
    • This is especially necessary for CI because while GitHub has version 9.0 installed, it is installed as latest

Notes

PR Checklist:

  • All new features have been tested
  • All new features have been documented
  • I have read the CONTRIBUTING.md file
  • I will abide by the code of conduct

@rmartin16 rmartin16 force-pushed the bump-android-cmdline-tools branch 5 times, most recently from aa9b9f1 to 71c68d7 Compare August 1, 2023 20:54
@rmartin16
Copy link
Member Author

rmartin16 commented Aug 1, 2023

During a cutover from a previous version of Briefcase to this one:

  • For Briefcase-managed SDK:
    • Briefcase will appear to do a fresh install of the Briefcase-managed Android SDK
    • However, it's just downloads the 9477386 cmdline-tools zip and unpacks it to android_sdk/cmdline-tools/9.0 while leaving the rest of the SDK in place
  • For an externally managed SDK:
    • If a version of cmdline-tools is installed as latest, then it will be used to install cmdline-tools;9.0
    • If a version of cmdline-tools is not installed as latest, a warning is shown and Briefcase's SDK is used

I think this approach provides a good strategy to creating better reproducibility with SDK use while also providing a repeatable method for bumping the Command-line Tools version. Please let me know if there's an aspect I'm failing to consider.

@rmartin16 rmartin16 marked this pull request as ready for review August 1, 2023 21:26
Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

This fundamentally all makes sense to me, and seems to work in my testing; however, I'd like @mhsmith to give it a quick once over to make sure I haven't missed anything subtle in the consequences of an Android update.

I'm also wondering if there's anything we can do around the cosmetics of the "existing user upgrade" process. I'm not overly concerned about having multiple versions of the SDK tools in the cache directory; however, having a "latest" folder that clearly isn't the latest any more seems like bad housekeeping (and potentially something that could bite us in future).

It's also a minor annoyance that the user-facing message is "couldn't find SDK", rather than "outdated SDK found". If you weren't expecting a download, you might interpret this as an indication that you've screwed up something and you've lost your old Briefcase configuration. Looking forward, I'm guessing that when we bump SDK_MANAGER_VER to "10.0" (or whatever), the same issue will arise - it will be identified as "not found", not "outdated".

  1. If A "latest" directory and "8092744" marker file exist, mark the install as an upgrade
  2. Maintain a list of "historical" SDK manager versions (currently empty) that, if a folder of that name exists in the cmdlinetools folder, causes theinstall to be marked as an upgrade

In case (2), all the "upgrade" flag does is modify the message; it doesn't do any cleanup of existing versions.

It might be worth doing a cleanup of case (1) to avoid having a latest folder that isn't the lastest version. My only hesitation on this is the churn for any user who is moving between old and new versions of briefcase. I'm not sure that's enough of a concern to be worried about, though.

@rmartin16
Copy link
Member Author

Great feedback; thanks.

I had some similar thoughts once I was going through some of the workflows.

wondering if there's anything we can do around the cosmetics of the "existing user upgrade"

There's currently a divergence for how this "upgrade" is handled for a Briefcase-managed SDK vs a User-managed SDK. Instead, if I just use the same method to install a specific version of the Command-line Tools for the Briefcase-managed SDK, then it won't look like fresh install and create that confusion. It will also leave the current install codepath to only run for an actually fresh install.

having a "latest" folder that clearly isn't the latest any more seems like bad housekeeping

My only hesitation on this is the churn for any user who is moving between old and new versions of briefcase.

Yeah; that's true...but even if someone is switching that much, the download isn't that large....and if they really want to, they could set up separate SDK installs for their purposes.

So, I'm thinking I'll just delete the latest directory if an "upgrade" is happening for the Briefcase-managed SDK.

@rmartin16
Copy link
Member Author

rmartin16 commented Aug 2, 2023

Realized there's a bit a bootstrapping problem with my idea. If I'm planning to delete the latest directory for Briefcase-managed SDKs, I can't very well depend on it in the future for installing the version that's needed....not to mention latest won't be available to installs after this release.

There is another option I was considering. In both these cases, Briefcase-managed and user-managed, we're depending on some hopefully existing state of the SDK to perform the upgrade. Alternatively, we could just download the cmdline-tools ZIP file, unpack it, and instead of installing the unpacked files in to the SDK location, just use the unpacked sdkmanager to perform the install in to the SDK location using the --sdk_root option. This is definitely a bit duplicative....but it also defers the actual install to sdkmanager itself and will work regardless of the state of the SDK.

@rmartin16
Copy link
Member Author

Here's what I think will help simplify this and create the best experience:

  • ANDROID_HOME is valued

    • If ANDROID_HOME doesn't "look like" an Android SDK root directory, inform the user the SDK file path isn't valid and proceed with Briefcase-managed SDK
  • Validate the SDK

    • The code flow for user-managed and Briefcase-managed SDKs converges at this point
    • If <SDK_ROOT>/cmdline-tools/<SDK_MGR_VER>/bin/sdkmanager exists, use the SDK
    • If the <SDK_ROOT> doesn't "look like" an Android SDK (or doesn't exist), perform a new install
      • This only applies to the Briefcase-managed SDK since the user SDK already passed this validation
    • Finally, install Command-line Tool version <SDK_MGR_VER> in to either the Briefcase or User SDK

"Looking like an Android SDK" is defined as containing at least one of the cmdline-tools, build-tools, or platform-tools directories.

Taking a closer look at what Android Studio does (as well as some of its source), it definitely appears to just download the 9477386 zip file and copy it in to the SDK at cmdline-tools/9.0.

Preparing "Install Android SDK Command-line Tools v.9.0".
Downloading https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip
"Install Android SDK Command-line Tools v.9.0" ready.
Installing Android SDK Command-line Tools in /opt/sdks/Android/sdk/cmdline-tools/9.0
"Install Android SDK Command-line Tools v.9.0" complete.
"Install Android SDK Command-line Tools v.9.0" finished.

Given this, I feel mostly comfortable with doing this procedure even for User-managed SDKs as well as the Briefcase-managed SDK.

@mhsmith
Copy link
Member

mhsmith commented Aug 2, 2023

That all sounds reasonable. But what does "perform a new install" mean beyond just installing the command-line tools?

@rmartin16
Copy link
Member Author

rmartin16 commented Aug 2, 2023

That all sounds reasonable. But what does "perform a new install" mean beyond just installing the command-line tools?

It really only changes what the user is told about what's happening. If no SDK exists, then the user is told "Android SDK not found; downloading and installing." Alternatively, if parts of the SDK already exist, they'll be told "Installing required SDK packages"....which would just be the specific version of cmdline-tools.

Given this, I feel mostly comfortable with doing this procedure even for User-managed SDKs as well as the Briefcase-managed SDK.

Unfortunately, though, this isn't proving entirely true. If you just download the ZIP file and unpack it in to an SDK that managed by Android Studio...Android Studio won't actually register the install in its UI. In the very least, when you run sdkmanager "cmdline-tools;9.0", it also creates a package.xml file that Android Studio ostensibly uses to actually register that a package has been installed.

Therefore, I don't think it's really safe to modify an externally-managed SDK without using sdkmanager.

However, we're back to the bootstrapping problem: if the sdkmanager is needed to install the sdkmanager, how can Briefcase reliably find an sdkmanager?

I'm thinking now it is safest to simply always download and unpack the needed version of cmdline-tools in to a Briefcase-managed SDK. That way, it can be used to reliably provide the sdkmanager to install the required version of cmdline-tools in to an externally-managed SDK.....or just facilitate using Briefcase-managed SDK like normal.

@rmartin16 rmartin16 marked this pull request as draft August 2, 2023 20:51
@freakboy3742
Copy link
Member

Given this, I feel mostly comfortable with doing this procedure even for User-managed SDKs as well as the Briefcase-managed SDK.

Unfortunately, though, this isn't proving entirely true. If you just download the ZIP file and unpack it in to an SDK that managed by Android Studio...Android Studio won't actually register the install in its UI. In the very least, when you run sdkmanager "cmdline-tools;9.0", it also creates a package.xml file that Android Studio ostensibly uses to actually register that a package has been installed.

This makes at least some sense; if the tools are downloaded in to cmdline-tools/9.0, how does Studio know which folder should be on the path (or should be used explicitly to reference sdkmanager)? When it downloaded into latest, the path to sdkmanager was predictable; 9.0 isn't, without additional metadata.

Therefore, I don't think it's really safe to modify an externally-managed SDK without using sdkmanager.

However, we're back to the bootstrapping problem: if the sdkmanager is needed to install the sdkmanager, how can Briefcase reliably find an sdkmanager?

I'm thinking now it is safest to simply always download and unpack the needed version of cmdline-tools in to a Briefcase-managed SDK. That way, it can be used to reliably provide the sdkmanager to install the required version of cmdline-tools in to an externally-managed SDK.....or just facilitate using Briefcase-managed SDK like normal.

That definitely make sense for the Briefcase-managed case; however, I'm not sure how it helps with the externally managed case. Unless Studio consistently produces a latest directory (which it used to do AFAIK, but it sounds like it might have stopped), we're going to need to discover the version that is currently installed.

I guess the good news is that the directory structure is just version numbers, so it's not too hard to discover the highest version number - but I'm not sure I'm wild about that as an approach.

@rmartin16
Copy link
Member Author

rmartin16 commented Aug 2, 2023

Given this, I feel mostly comfortable with doing this procedure even for User-managed SDKs as well as the Briefcase-managed SDK.

Unfortunately, though, this isn't proving entirely true. If you just download the ZIP file and unpack it in to an SDK that managed by Android Studio...Android Studio won't actually register the install in its UI. In the very least, when you run sdkmanager "cmdline-tools;9.0", it also creates a package.xml file that Android Studio ostensibly uses to actually register that a package has been installed.

This makes at least some sense; if the tools are downloaded in to cmdline-tools/9.0, how does Studio know which folder should be on the path (or should be used explicitly to reference sdkmanager)? When it downloaded into latest, the path to sdkmanager was predictable; 9.0 isn't, without additional metadata.

If one downloads and installs Android Studio today, it doesn't install any version of cmdline-tools in to the SDK it creates. This was my experience anyway.

Therefore, I don't think it's really safe to modify an externally-managed SDK without using sdkmanager.
However, we're back to the bootstrapping problem: if the sdkmanager is needed to install the sdkmanager, how can Briefcase reliably find an sdkmanager?
I'm thinking now it is safest to simply always download and unpack the needed version of cmdline-tools in to a Briefcase-managed SDK. That way, it can be used to reliably provide the sdkmanager to install the required version of cmdline-tools in to an externally-managed SDK.....or just facilitate using Briefcase-managed SDK like normal.

That definitely make sense for the Briefcase-managed case; however, I'm not sure how it helps with the externally managed case. Unless Studio consistently produces a latest directory (which it used to do AFAIK, but it sounds like it might have stopped), we're going to need to discover the version that is currently installed.

I don't think I'm following...I'm simply proposing that Briefcase keeps a copy of the cmdline-tools that is manages regardless of whether an externally-managed SDK is specified by the user.

Does that make sense?

If Briefcase has a reliable copy of cmdline-tools that it manages, then it can safely interact with externally-managed SDKs. Although, presently, it would only be used to install a copy of cmdline-tools in to the externally-managed SDK.

I'm proposing this for 3 goals:

  1. Solve the bootstrapping problem of needing an sdkmanager without knowing where one will be (or if one even exists)
  2. Use a reliable version of sdkmanager across all Briefcase installs
  3. Prevent requiring users manually install a specific version of cmdline-tools to use an SDK with Briefcase

@rmartin16
Copy link
Member Author

rmartin16 commented Aug 2, 2023

Oh...in case I haven't brought this up...

The sdkmanager supports interacting with arbitrary SDKs installed elsewhere in the filesystem.

❯ ~/.cache/briefcase/tools/android_sdk/cmdline-tools/9.0/bin/sdkmanager --help
...
    --sdk_root=<sdkRootPath>: Use the specified SDK root instead of the SDK
                              containing this tool
...

@freakboy3742
Copy link
Member

If one downloads and installs Android Studio today, it doesn't install any version of cmdline-tools in to the SDK it creates. This was my experience anyway.

How does an Android SDK user get a command line sdkmanager? It might not be installed by default, but my understanding was that it was selectable from the in-Studio GUI for package management.

I don't think I'm following...I'm simply proposing that Briefcase keeps a copy of the cmdline-tools that is manages regardless of whether an externally-managed SDK is specified by the user.

Does that make sense?

If Briefcase has a reliable copy of cmdline-tools that it manages, then it can safely interact with externally-managed SDKs. Although, presently, it would only be used to install a copy of cmdline-tools in to the externally-managed SDK.

Is it going to be safe for a Briefcase-managed SDK instance to alter a non-briefcase managed SDK install? It seems like asking for trouble to me...

For my money, supporting ANDROID_HOME at all is an optimisation for people who know what they're doing. We should certainly make an effort to make the user-managed experience nice, but I think it's also reasonable to expect a user who wants to use a user-managed SDK install to... you know... manage their SDK install :-)

To that end, I'd suggest the following behavior:

  1. Briefcase-managed install
    1. If a 9.0 sdk manager exists, use it
    2. If a latest directory and 8092744 marker file exist, do an upgrade to 9.0, then delete the old versions
    3. If no SDK exists, download the 9.0 zipfile.
    4. Modify the code (as you've done in the PR) to reference a specific version of the cmdline-tools.
  2. User-managed install
    1. If a 9.0 sdkmanager exists, use it
    2. If a latest sdkmanager exists, use it to install 9.0. Notify the user that the latest folder might need to be cleaned up because it's not "latest" any more.
    3. Otherwise, tell the user that they have a user-managed SDK that doesn't have sdkmanager, so they should either install cmdline-tools;9.0 with Android Studio, or unset ANDROID_HOME to let briefcase manage it.

It might be possible to extend (2.ii) to include a couple of other likely candidates (e.g., looking for cmdline-tools;6.0, cmdline-tools;7.0 etc); but unless there's a reliable way for us to get the cmdline-tools installed into a user-managed SDK instance, I think it's better to raise an error than risk messing up their install.

@rmartin16
Copy link
Member Author

How does an Android SDK user get a command line sdkmanager? It might not be installed by default, but my understanding was that it was selectable from the in-Studio GUI for package management.

It is an optional selection within the Studio's Android SDK management UI.

Is it going to be safe for a Briefcase-managed SDK instance to alter a non-briefcase managed SDK install? It seems like asking for trouble to me...

I don't really see any reason to think this would be a problem; sdkmanager has an explicit option to interact with arbitrary SDK installations.

To that end, I'd suggest the following behavior:

This is basically what my previous commit is; I'm fine with this approach.

Furthermore, though, I think we should get away from unpacking the cmdline-tools zip file in to the Briefcase-managed SDK. It is quite clear to me at this point this isn't really considered a valid installation by the Command-line Tools themselves. For instance, if you run sdkmanager --list-installed after doing this, it doesn't include the just unpacked cmdline-tools. However, if you instead just use the unpacked sdkmanager to install cmdline-tools;9.0 in to the Briefcase-managed SDK, it is properly seen as a package installed in the SDK. This is also why if you just copy the contents of the zip file in to Studio's managed copy of the SDK, it doesn't register it as installed either.

- Previously, Android's Command-line Tools were installed into
  `cmdline-tools/latest` by Briefcase.
- However, the SDK supports a versioned layout for installed packages.
  Therefore, the Command-line Tools are now installed in to
  `cmdline-tools/9.0` in the Briefcase data directory.
- This also ensures that user-provided SDKs are providing the same
  version of Command-line Tools as Briefcase installs.
@rmartin16
Copy link
Member Author

rmartin16 commented Aug 5, 2023

  • Briefcase-managed install

    1. If a 9.0 sdk manager exists, use it
    2. If a latest directory and 8092744 marker file exist, do an upgrade to 9.0, then delete the old versions
    3. If no SDK exists, download the 9.0 zipfile.
    4. Modify the code (as you've done in the PR) to reference a specific version of the cmdline-tools.
  • User-managed install

    1. If a 9.0 sdkmanager exists, use it
    2. If a latest sdkmanager exists, use it to install 9.0. Notify the user that the latest folder might need to be cleaned up because it's not "latest" any more.
    3. Otherwise, tell the user that they have a user-managed SDK that doesn't have sdkmanager, so they should either install cmdline-tools;9.0 with Android Studio, or unset ANDROID_HOME to let briefcase manage it.

This is implemented now. The only deviation is notifying the user about latest in their SDK when we use it to install version 9.0. I don't think this is necessary; the install of version 9.0 is independent of whatever is in latest and doesn't impact any future use of latest.

Additionally, though, I guess I had never actually really paid attention to the build output:

> Configure project :app
Warning: Python version 3.10 may have fewer packages available. If you experience problems, try switching to version 3.8.
Checking the license for package Android SDK Tools in /home/russell/.cache/briefcase/tools/android_sdk/licenses
License for package Android SDK Tools accepted.
Preparing "Install Android SDK Tools (revision: 26.1.1)".
"Install Android SDK Tools (revision: 26.1.1)" ready.
Installing Android SDK Tools in /home/russell/.cache/briefcase/tools/android_sdk/tools
"Install Android SDK Tools (revision: 26.1.1)" complete.
"Install Android SDK Tools (revision: 26.1.1)" finished.
Checking the license for package Android SDK Build-Tools 30.0.3 in /home/russell/.cache/briefcase/tools/android_sdk/licenses
License for package Android SDK Build-Tools 30.0.3 accepted.
Preparing "Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)".
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" ready.
Installing Android SDK Build-Tools 30.0.3 in /home/russell/.cache/briefcase/tools/android_sdk/build-tools/30.0.3
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" complete.
"Install Android SDK Build-Tools 30.0.3 (revision: 30.0.3)" finished.
Checking the license for package Android SDK Platform 33 in /home/russell/.cache/briefcase/tools/android_sdk/licenses
License for package Android SDK Platform 33 accepted.
Preparing "Install Android SDK Platform 33 (revision: 2)".
"Install Android SDK Platform 33 (revision: 2)" ready.
Installing Android SDK Platform 33 in /home/russell/.cache/briefcase/tools/android_sdk/platforms/android-33
"Install Android SDK Platform 33 (revision: 2)" complete.
"Install Android SDK Platform 33 (revision: 2)" finished.

But...now I know where the tools directory keeps coming from in the Briefcase-managed SDK...since version 26.1.1 of the SDK Tools is what Briefcase calls "legacy" Android SDK and tries to delete at start up.

This also made me realize what's installing build-tools as well.....but I can't find the specific version mentioned anywhere.

Is this all controlled by the Briefcase android template? or something else?

[edit]
I'm guessing this is all stemming from the lines below in build.gradle:

apply plugin: 'com.android.application'
apply plugin: 'com.chaquo.python'

@rmartin16 rmartin16 marked this pull request as ready for review August 5, 2023 22:04
@freakboy3742
Copy link
Member

The only deviation is notifying the user about latest in their SDK when we use it to install version 9.0. I don't think this is necessary; the install of version 9.0 is independent of whatever is in latest and doesn't impact any future use of latest.

I know it doesn't impact on usage - my argument for the warning was that if the user can end up with a "latest" folder that isn't actually the latest, then that's a foot-gun waiting to go off. However, it's also a user-managed SDK install, and we're using the factory-provided "upgrade" mechanism, so if it doesn't do the right thing, I'm also happy to put this in the "you said you want to manage your SDK install - so manage it" basket.

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

One clarification, and a couple of cosmetic cleanups; but I we're getting close.

of the Android SDK instance such that

${sdk_env_source}/cmdline-tools/latest/bin/sdkmanager
${sdk_source_env}/cmdline-tools/{cls.SDK_MANAGER_VER}/bin/sdkmanager
Copy link
Member

Choose a reason for hiding this comment

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

Minor nit - this instruction won't be right on Windows, because of the .bat extension. Might as well clean this up while we're in the area.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch; updated to use the existing methods to get the path for sdkmanager.

tools.logger.info(
"To use an existing Android SDK instance, specify its root "
"directory path in the ANDROID_HOME environment variable."
)
Copy link
Member

Choose a reason for hiding this comment

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

IMHO, if someone already has a working Briefcase install and is upgrading, there's no need to let them know that they can use an existing Android SDK instance. I think we can bury the "to use an existing" warning unless we're doing a first install.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. Details about ANDROID_HOME are only shown now for a new install.

src/briefcase/integrations/android_sdk.py Show resolved Hide resolved
src/briefcase/integrations/android_sdk.py Show resolved Hide resolved
@rmartin16
Copy link
Member Author

The only deviation is notifying the user about latest in their SDK when we use it to install version 9.0. I don't think this is necessary; the install of version 9.0 is independent of whatever is in latest and doesn't impact any future use of latest.

I know it doesn't impact on usage - my argument for the warning was that if the user can end up with a "latest" folder that isn't actually the latest, then that's a foot-gun waiting to go off. However, it's also a user-managed SDK install, and we're using the factory-provided "upgrade" mechanism, so if it doesn't do the right thing, I'm also happy to put this in the "you said you want to manage your SDK install - so manage it" basket.

I'm still not following, though; this seems to be the nature of the beast that Google has created. Whatever is in the latest directory is in the latest directory...it doesn't seem to have anything to do with independent installs of other versions of cmdline-tools. For instance, if I go in to Android Studio and ask it to install version 9.0 of cmdline-tools, then the latest directory remains whatever it was before.

TBH, I don't know why Google has this designation of latest....it seems like a strange holdover from legacy design of the Android SDK tools. Maybe running sdkmanger --update updates latest to entirely new versions of the SDK....either way, the version installed as 9.0 is still independent. I also don't understand why Google even recommends people use latest...it seems to come right out of their "canary" branch 😕

Do I have the wrong understanding of the Android SDK tools? I just feel like this would be a strange warning given my understanding of cmdline-tools at this point....given that if the user cares about what's in latest, they wouldn't seem to really care that other versions of the tools are also installed now.

@freakboy3742
Copy link
Member

Do I have the wrong understanding of the Android SDK tools? I just feel like this would be a strange warning given my understanding of cmdline-tools at this point....given that if the user cares about what's in latest, they wouldn't seem to really care that other versions of the tools are also installed now.

It's entirely possible I have the wrong understanding. I know that when I set up the cmdline-tools (the v6 version we're purging here), it installed into latest, or at least needed to be called latest if you wanted it to work. At that time, the ARM64 emulator was only just out of experimental phase, so it's possible the latest name was a reflection of the fact that the code was very fresh.

I assumed that latest was effectively a symlink - you could install whatever version you wanted, and latest would point at the version that was installed; you could set your path to cmdline-tools/latest/bin and just run sdkmanager. If that's not the case, and latest is some sort of "canary" reference, then the sort of update/cleanup that I'm describing doesn't make any sense.

Either way - I think it's a moot point. We're definitely cleaning up latest for Briefcase-managed SDKs; an explicit 9.0 is much better, and we don't have PATH naming consistency issues to worry about. If it's a user-managed SDK, I wouldn't want to delete anything, and even a warning could be more confusion than help - especially if I've got the wrong end of the stick about what "latest" means. As long as they've got a 9.0 version in their install, we can use it.

@rmartin16
Copy link
Member Author

Do I have the wrong understanding of the Android SDK tools? I just feel like this would be a strange warning given my understanding of cmdline-tools at this point....given that if the user cares about what's in latest, they wouldn't seem to really care that other versions of the tools are also installed now.

It's entirely possible I have the wrong understanding. I know that when I set up the cmdline-tools (the v6 version we're purging here), it installed into latest, or at least needed to be called latest if you wanted it to work. At that time, the ARM64 emulator was only just out of experimental phase, so it's possible the latest name was a reflection of the fact that the code was very fresh.

This is still Google's recommendation....although, given that sdkmanager doesn't even recognize a cmdline-tools version installed like this, it seems a little half-baked.

I assumed that latest was effectively a symlink - you could install whatever version you wanted, and latest would point at the version that was installed; you could set your path to cmdline-tools/latest/bin and just run sdkmanager. If that's not the case, and latest is some sort of "canary" reference, then the sort of update/cleanup that I'm describing doesn't make any sense.

As best I can tell, latest is just the "dev" branch for cmdline-tools. In at least one place, it made it seem like 9.0 is stable, 10.0 is beta, and 11.0 is canary. I imagine once 10.0 becomes stable, it all shifts forward one.

Either way - I think it's a moot point. We're definitely cleaning up latest for Briefcase-managed SDKs; an explicit 9.0 is much better, and we don't have PATH naming consistency issues to worry about. If it's a user-managed SDK, I wouldn't want to delete anything, and even a warning could be more confusion than help - especially if I've got the wrong end of the stick about what "latest" means. As long as they've got a 9.0 version in their install, we can use it.

I would also like to manage the other tools that are installed...that is, the build-tools and the Android platform. In that way, we could ensure the Briefcase-managed SDK doesn't contain unneeded versions of those as well.

However, it seems this will require much more cooperation with what the APK build process does....since that's pretty opaque to me, I'm not sure how well that would all work out.

@rmartin16
Copy link
Member Author

rmartin16 commented Aug 7, 2023

As best I can tell, latest is just the "dev" branch for cmdline-tools. In at least one place, it made it seem like 9.0 is stable, 10.0 is beta, and 11.0 is canary. I imagine once 10.0 becomes stable, it all shifts forward one.

Additionally, Google is maintaining two different definitions of latest.

If you download the "latest" version of Command-line Tools from their website, it is version 9.0.

If you run sdkmanager --install 'cmdline-tools;latest', it installs version 11.0 in the latest directory.

This is how this is communicated in the Studio SDK manager UI:
image

So, staying true to everything else Android....this all makes perfect sense 🙃

@freakboy3742
Copy link
Member

As best I can tell, latest is just the "dev" branch for cmdline-tools. In at least one place, it made it seem like 9.0 is stable, 10.0 is beta, and 11.0 is canary. I imagine once 10.0 becomes stable, it all shifts forward one.

👍

I would also like to manage the other tools that are installed...that is, the build-tools and the Android platform. In that way, we could ensure the Briefcase-managed SDK doesn't contain unneeded versions of those as well.

However, it seems this will require much more cooperation with what the APK build process does....since that's pretty opaque to me, I'm not sure how well that would all work out.

Conceptually, I'm on board with this as an idea; with the obligatory "but you gotta make it work first" caveats :-)

Copy link
Member

@freakboy3742 freakboy3742 left a comment

Choose a reason for hiding this comment

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

One cosmetic tweak to an uninstall message, but otherwise, this looks really good. Thanks for your persistence with wrangling Android (and myself) through this.

@freakboy3742 freakboy3742 merged commit 650ad94 into beeware:main Aug 8, 2023
32 of 35 checks passed
@rmartin16 rmartin16 deleted the bump-android-cmdline-tools branch August 8, 2023 13:39
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.

3 participants