Installing Android SDK Without Android Studio
Google makes this too hard
I teach a course with Flutter, Google’s cross-platform UI toolkit. Flutter has really impresssed me. It’s thoughtful, comprehensive, and easy to install.
Many students in my class use Android. Many use iOS. Some use both. That diversity is one reason why we picked Flutter. It’s not so motivating to learn to make mobile apps when you can’t run those apps on the device you carry with you every day. Flutter provides excellent support for iOS and Android, among other targets.
It’s quite common for students to have older, slower computers. Often, they are low on disk space. Android Studio is big – at least 3GB. That might not seem like much, but when you’re 4 years into school and have a 5 year old laptop, that might be a large percentage of the disk space you have available on your computer.
For that reason, we (the course team) wanted to help students to get the Android SDK and associated tools working without needing Android Studio. This seems, lamentably, to be a path that Google does not officially support. They used to. They don’t now. I don’t know why. It’s annoying – if you’re an Android PM reading this, please reconsider your decisions. Go find someone from Flutter to show you how to treat your developers well, because this ain’t it.
There is not good documentation online about how to do this. The process is similar on macOS, Windows, and Linux. Here are the key steps:
- Install Java 17.
- Make sure to select version 17. You’ll have issues if you use a newer version.
- If installing on Windows, unless you have a strong reason not to, take the Installer up on its offer to stick this Java in your PATH.
- If you have multiple versions of Java installed, you may have to select to use this version before running various Android tools, or using Gradle scripts for Android. Here is how to do that on macOS. Similar processes apply on Linux and Windows.
- Download the Android SDK.
- The links to do this are most of the way down the Android Studio download page.
- Don’t get tricked by the Dark Pattern on the page into accidentally downloading Android Studio. Your download should be around 100MB, not 1GB (that’s about 4 orders of magnitude difference if we count in binary).
- Unzip it.
- Rename the unzipped directory from
cmdline-tools
tolatest
. - Now make some directories to contain it.
- You want to end up with
latest
being nested inside the parent directoriesandroid/sdk/cmdline-tools
. - If you’re on macOS or Linux, you could accomplish this by doing
mkdir -p android/sdk/cmdline-tools && mv latest android/sdk/cmdline-tools
. - There’s probably a quick way to do this on Windows, but I don’t know Windows well enough to know a way that doesn’t just involve a lot of right-clicking and making new folders. So do that. If you know a better way, please tell me.
- Stick that whole tree someplace you won’t forget. Don’t use your desktop or any place like that. On my Mac, I put it in
~/Library
. On Linux, I tend to keep a~/lib
and that’s a fine place. On Windows,c:\android
is fine. - Add the full path to
...latest/bin
to your PATH.
- On Windows, you can do that by clicking the Start button (or whatever MS calls it now), typing
Envir
and choosing the option to edit your local environment variables. Then, double click onPath
click theNew
button, and browse deep down into the directory structure you created until you’re atbin
. - On Linux and macOS, stick it in your
.bashrc
,.zshrc
, or whatever rcfile matches your preferred shell. On my Mac, I did it by sticking this into my~/.zshrc
:
export ANDROID_HOME=~/Library/Android/sdk
export ANDROID_TOOLS_PATHS=$ANDROID_HOME/cmdline-tools/latest/bin:
export PATH=$ANDROID_TOOLS_PATHS:$PATH:
- Just to make sure things are configured right, log out and log back in.
- Now, in your terminal, you should be able to execute the following commands. This will get you the almost-newest versions of the various Android tools and system images that you need.
sdkmanager "platforms;android-33"
sdkmanager "platform-tools"
sdkmanager "build-tools;33.0.2"
sdkmanager emulator
sdkmanager "system-images;android-33;google_apis;x86_64"
sdkmanager --licenses
- Before you paste the lines above in: If appropriate, change the x86_64 above to match your computer’s architecture. Most likely, this is only necessary if you’re on an Apple Silicon (M1/M2/…) Mac. In that case, use
arm64-v8a
. - Say yes when prompted to agree to the various license terms.
- Windows Only: Enable a hypervisor. Microsoft has decent instructions here.
You should be all set.
Many thanks to Kris Venden and Lauren Bricker for screaming into the void alongside me as we figured this out.