~/t/g/mac $

Android SDK filling your Mac? Move it to an external SSD

gist Back up and copy the SDK, point your tools at the external path, and keep the original until tool checks and a project build pass.

contents
  1. Step 1: Choose one SDK location
  2. Step 2: Back up and copy the SDK folder
  3. Step 3: Set the shell path and check readability
  4. Step 4: Point Android Studio and Gradle at the copy
  5. Step 5: Verify tools and a project build
  6. Step 6: Handle emulator storage separately
  7. Alternatives
  8. Common questions

If the Android SDK is filling your Mac, copy it to an external SSD and point Android Studio, Gradle and your shell at the same location.

I use Android emulators and SDK on an external NVMe on my Mac mini.

Start with a backup, enough free space on the external drive and a working SDK installation. Copy the SDK first. Keep the original until the tools and a project build work with the new path.

Step 1: Choose one SDK location

Use one folder for the SDK root. Replace /Volumes/ExampleSSD/android/sdk with your drive’s actual location.

Open Tools > SDK Manager in Android Studio and note the current Android SDK Location. This is the folder to copy. SDK Manager stores downloaded packages beneath that root. Android SDK Manager documentation

  • External SSD SDK: /Volumes/ExampleSSD/android/sdk
  • ANDROID_HOME and tool PATH: point into that SDK
  • Android Studio and Gradle: use the same SDK root

AVD storage has its own setting. Moving the SDK alone does not move the virtual devices’ writable disk images. Android environment variables

Diagram: the external SDK path must agree across shell tools, Android Studio and Gradle.
Three places name the SDK. If any one still points at the old folder, that tool keeps using it.

Step 2: Back up and copy the SDK folder

Back up the existing SDK before changing its location. Stop builds, close Android Studio and shut down running emulators.

Copy the whole SDK folder to the external drive. Preserve its contents and executable permissions. Avoid merging it into another SDK installation. On a Mac, ditto copies a folder with its permissions intact:

ditto "$HOME/Library/Android/sdk" /Volumes/ExampleSSD/android/sdk

Use the SDK location you noted in Step 1 as the source.

Check the resulting layout. If the original contains platform-tools, the copy should have /Volumes/ExampleSSD/android/sdk/platform-tools, rather than an extra nested sdk folder.

Keep licenses and all installed package folders in the copy. Gradle uses accepted licenses when downloading missing SDK packages. SDK package and license documentation

Leave the original in place while checking the copy.

Step 3: Set the shell path and check readability

ANDROID_HOME names the SDK root. ANDROID_SDK_ROOT is deprecated. Remove an old definition, or ensure it matches ANDROID_HOME if another tool still needs it. Android environment variables

After copying, check the mounted volume, folder access and tool discovery:

(
  export ANDROID_HOME="/Volumes/ExampleSSD/android/sdk"

  test -d "/Volumes/ExampleSSD" || {
    printf '%s\n' "External volume is missing."
    exit 1
  }

  test -d "$ANDROID_HOME" &&
    test -r "$ANDROID_HOME" &&
    test -x "$ANDROID_HOME" || {
      printf '%s\n' "SDK folder is missing or inaccessible."
      exit 1
    }

  export PATH="$ANDROID_HOME/platform-tools:$ANDROID_HOME/cmdline-tools/latest/bin:$PATH"

  command -v adb
  command -v sdkmanager
  test -x "$ANDROID_HOME/platform-tools/adb"
)

The parentheses keep these settings inside this shell session. For regular use, add the two export lines to the startup file your shell reads. Open a fresh terminal afterward.

Check that discovered tools resolve inside the external SDK. If they still resolve to the old installation, remove stale SDK entries from your shell configuration.

The cmdline-tools/latest/bin path applies when that directory exists. Some installations use a numbered command-line tools directory instead. Match your installed layout. Current documentation deprecates sdkmanager in favor of Android CLI’s android sdk command; existing Command-Line Tools installations can still contain sdkmanager. Command-line package tools

Step 4: Point Android Studio and Gradle at the copy

In Android Studio’s SDK Manager, change Android SDK Location to /Volumes/ExampleSSD/android/sdk. Confirm that the expected installed packages appear.

Set the GUI location explicitly. A terminal export only affects that shell and processes launched from it.

Check each project’s local.properties file. Its sdk.dir entry should name the same external SDK root. Preserve other valid entries in the file. For a React Native project, look in the Android project directory.

Android documents sdk.dir as the SDK path used by the build configuration. Android build configuration

Step 5: Verify tools and a project build

Before retiring the original SDK:

  1. Open a fresh terminal and check tool discovery again.
  2. Reopen Android Studio and confirm its SDK location and installed packages.
  3. Sync an existing project.
  4. Build that project with its usual debug task from the directory containing its Gradle wrapper.

For a standard Android project, use:

./gradlew assembleDebug

Projects with product flavors may use a more specific task. Android command-line builds

If using the existing sdkmanager, its --list option lists packages, and --sdk_root selects a specific SDK directory. Package listing can contact repositories. Use the installed-package section to check the copy. sdkmanager options

Resolve missing packages, permissions and stale paths before deleting anything. Once the checks and build pass, remove the old SDK when you are ready to reclaim the space. Keep your backup.

Step 6: Handle emulator storage separately

SDK system-image packages and AVD writable files are separate. ANDROID_AVD_HOME controls the AVD-specific files, which include large disk images. Changing ANDROID_HOME does not relocate them. AVD environment variables

Treat AVD relocation as a separate change. Back up existing virtual devices and check their paths before moving their files. The emulator storage guide covers that move.

Gradle stores caches in both its user home and project directories. On a Mac, the default Gradle user home is ~/.gradle; GRADLE_USER_HOME can change it. Copying the SDK does not relocate those directories. Gradle directories and caches

Keep the SSD connected while builds or emulators use it. Eject it before unplugging. If macOS reports that it is busy, close the applications using it and try again. Apple’s disk-ejection guidance

Alternatives

Option When it fits Tradeoff
External SSD SDK Internal space is tight and the drive can stay connected Tools depend on the drive being mounted at the expected path
Internal SDK storage Portability and fewer path settings matter most Packages consume internal storage
Remove unused SDK packages Old platforms or tools account for much of the space Projects may need those packages again
Separate build hardware Builds already run on another machine That machine needs its own SDK, storage and build setup

Android Studio’s SDK Manager supports package removal: clear an installed package’s checkbox, review the pending removals, then click Apply or OK. Check your projects’ requirements before removing platforms or tools. SDK Manager package removal

Common questions

Can I put the Android SDK on an external SSD?

Yes. Use the external folder as the SDK root, then align Android Studio, ANDROID_HOME, tool paths and each project’s sdk.dir.

Why does Gradle say SDK location not found after moving it?

Check that the drive is mounted and the SDK folder is readable. Then inspect local.properties for the old path and check ANDROID_HOME in the shell that starts the build.

Should I use ANDROID_HOME or ANDROID_SDK_ROOT?

Use ANDROID_HOME. ANDROID_SDK_ROOT is deprecated. If retained for compatibility, it must agree with ANDROID_HOME.

Does moving the SDK move my Android emulators?

It moves any system-image packages inside the SDK folder. It does not automatically move AVD writable files. Those have a separate location.

Can I delete the original SDK immediately?

Keep it until tool checks, Android Studio sync and a project build pass with the external path. If a check fails, point the tools back to the original while fixing the copy.

What happens if the external SSD is unplugged?

Tools that need that SDK cannot use the configured location. Reconnect the drive and confirm its mount path before starting another build.

Related: Mac guides · guide index.

../mac/ every Mac guide