Add skip android home install command#200
Open
dfabulich wants to merge 2 commits intoskiptools:mainfrom
Open
Conversation
This was referenced Mar 2, 2026
This command will ensure that cmdline-tools is installed in `$ANDROID_HOME`, which will be `~/Library/Android/sdk` on macOS by default. This works with or without Android Studio installed, creating the directory if it doesn't exist yet. If cmdline-tools are not installed, we can "bootstrap" them by running _any_ `sdkmanager` we can find. Our Homebrew cask installs `android-commandlinetools`, which installs its own Android SDK (probably _not_ the one the user wants to use). We can use that to run `sdkmanager --sdk_root=$ANDROID_HOME "cmdline-tools;latest"` to install the command line tools into Android Studio's SDK; then we can use the cmdline-tools in `$ANDROID_HOME`.
1. We now use the new `ensureCmdlineTools` function from `skip android home install` 2. We ask `emulator` for the list of AVDs, skipping creating the AVD if it already exists. (Despite the claim of `--force`, in my experiments, I found that it wasn't able to overwrite an existing AVD, e.g. to change the system_image.) 3. If there's no existing emulator with that name, we can finally create the emulator with a known-good `avdmanager` in `ANDROID_HOME`'s `cmdline-tools`. Fixes skiptools#187
49e5ae2 to
85b2617
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This command will ensure that cmdline-tools is installed in
$ANDROID_HOME, which will be~/Library/Android/sdkon macOS by default. This works with or without Android Studio installed, creating the directory if it doesn't exist yet.If cmdline-tools are not installed, we can "bootstrap" them by running any
sdkmanagerwe can find. Our Homebrew cask installsandroid-commandlinetools, which installs its own Android SDK (probably not the one the user wants to use). We can use that to runsdkmanager --sdk_root=$ANDROID_HOME "cmdline-tools;latest"to install the command line tools into Android Studio's SDK location; then we can use the cmdline-tools in$ANDROID_HOME.I think it would make sense to run
skip android home installas apostflightstep of our Homebrew cask.In addition, this PR updates
skip android emulator createto automatically ensure cmdline-tools are set up if they aren't already. That fixes #187 and #188 (This replaces PR #194, which I closed in favor of this one)I'm not able to fully test this in UTM. What I did:
swiftlyopenjdkgradleandandroid-commandlinetools(the dependencies in https://github.com/skiptools/homebrew-skip/blob/main/Casks/skip.rb)swiftly init --asume-yes --no-modify-profile --skip-installskipstone/scriptsto my$PATH.skip android home install, which workedskip android emulator create, which also workedPATH=~/stonehack/skipstone/scripts:$PATH skipstone/scripts/skip checkupfrom the..directory containingskipstone(to workaround Using a local Skip build requires updatingPackage.swift#190), which also worked/opt/homebrewor in another place Android Studio couldn't see.Skip Pull Request Checklist:
swift test