Skip to content

The Android SDK keeps a system image for every API level you tried

Platforms, build tools and system images accumulate per API level. Which command lists them and which removes them.

4 min read

The Android SDK grows in a specific way: every API level you have ever built against or emulated leaves a platform, a set of build tools and, worst of all, a system image. A system image is a complete Android installation and they are gigabytes each.

Where it all is

du -sh ~/Library/Android/sdk 2>/dev/null
du -sh ~/Library/Android/sdk/* 2>/dev/null | sort -h | tail
du -sh ~/Library/Android/sdk/system-images/* 2>/dev/null | sort -h
FolderWhat it isSafe to remove
system-imagesA full Android per API level and ABIYes, redownloaded
platformsSDK per API levelYes, if nothing targets it
build-toolsOne per versionYes, keep what projects use
ndkNative development kits, largeYes, if you do not build native code
emulatorThe emulator itselfKeep if you emulate

Listing and removing properly

sdkmanager --list_installed
sdkmanager --uninstall "system-images;android-30;google_apis;x86_64"
sdkmanager --uninstall "platforms;android-30"

Using sdkmanager rather than deleting folders keeps the SDK's own manifest accurate, which matters because Android Studio checks it and will otherwise offer to repair an install that looks damaged.

What your projects actually need

grep -rh 'compileSdk\|targetSdk' ~/**/build.gradle* 2>/dev/null | sort -u | head

That prints the API levels your projects compile and target. Anything installed well below the lowest of those, and not used by an emulator you keep, is a candidate for removal.

The emulator side

Virtual devices are separate from system images and are worth checking at the same time, since a device with a large data partition holds everything installed inside it. That is covered along with the rest of the toolchain in Android Studio's disk usage, and the Gradle side is in the .gradle folder.

Common questions

Where is the Android SDK on a Mac?

By default in ~/Library/Android/sdk, containing platforms, build tools, NDK versions and system images. System images are usually the largest part, at gigabytes per API level.

How do I remove old Android system images?

Use sdkmanager --list_installed to see what is there, then sdkmanager --uninstall with the package name. That keeps the SDK manifest consistent, unlike deleting folders.

Which API levels can I remove?

Anything well below the lowest compileSdk or targetSdk across your projects, and any image for a device you no longer emulate. A grep across your build files shows what is actually needed.

Is the NDK safe to remove?

Yes, if you do not build native code. Each NDK version is several gigabytes and they accumulate, so removing versions no project references is usually a significant reclaim.

Read next