Skip to content

Add skip android home install command#200

Open
dfabulich wants to merge 2 commits intoskiptools:mainfrom
dfabulich:android-home-install
Open

Add skip android home install command#200
dfabulich wants to merge 2 commits intoskiptools:mainfrom
dfabulich:android-home-install

Conversation

@dfabulich
Copy link
Contributor

@dfabulich dfabulich commented 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 location; then we can use the cmdline-tools in $ANDROID_HOME.

I think it would make sense to run skip android home install as a postflight step of our Homebrew cask.

In addition, this PR updates skip android emulator create to 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:

  • I followed my installation test plan Installation test plan skip#632 up to step 4i.
  • I skipped installing Android Studio
  • I installed Homebrew and manually installed swiftly openjdk gradle and android-commandlinetools (the dependencies in https://github.com/skiptools/homebrew-skip/blob/main/Casks/skip.rb)
  • I ran swiftly init --asume-yes --no-modify-profile --skip-install
  • I installed Xcode and iOS platform support
  • I checked out my branch and built it, adding skipstone/scripts to my $PATH.
  • I ran skip android home install, which worked
  • I ran skip android emulator create, which also worked
  • I ran PATH=~/stonehack/skipstone/scripts:$PATH skipstone/scripts/skip checkup from the .. directory containing skipstone (to workaround Using a local Skip build requires updating Package.swift #190), which also worked
  • I did not launch the emulator, because I can't run emulators in UTM.
  • I downloaded Android Studio, clicked Next Next Next.
  • I opened Android Studio's SDK manager. It detected that command-line tools were already installed.
  • I opened Android Studio's Virtual Device manager. It detected the emulator that we'd created from the command-line, ensuring that we didn't create the emulator in /opt/homebrew or in another place Android Studio couldn't see.

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

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
@dfabulich dfabulich force-pushed the android-home-install branch from 49e5ae2 to 85b2617 Compare March 2, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

skip android emulator create fails on fresh install

1 participant