Today I wanted to diagnose a problem on my Android phone. It had been a while since I wrote any Android code, so adb wasn’t installed on my computer. I decided to just quickly install the Android command line tools, rather than the full SDK. This turned out not to be so quick after all. In the end, I had to download the tools, extract them into a particular folder hierarchy, move some files around, install Java, and set some environment variables. It’s like someone was trying to make this difficult! Here’s what worked for me on Windows 10. Maybe it will help someone else.
- Downloaded and Installed the Java Runtime Environment (currently version 8 update 241).
- Download the latest Android command line tools. That’s
commandlinetools-win-6200805_latest.zipat the time I’m writing this.
- Extracted to
C:\android\cmdline-tools\latest, following the guidance here. To clarify, the downloaded zip file contained a folder named
tools, and I renamed that folder to
latestand placed it in
C:\android\cmdline-tools. Why would a specific folder structure be required? I don’t know, and I’m not taking the time now to investigate.
- Followed the advice here and copied the files in
latest\lib. This doesn’t feel right to me… why would the zip file include a folder structure that doesn’t work? I’m sure there’s more going on here, but for now I’m going with that works.
- Added an environment variable named
ANDROID_HOMEand set it to
- Opened a cmd prompt and ran
sdkmanager "platform-tools". This installed adb and more to
- With my Android device connected to my PC with USB debugging enabled, checked that adb is working by running
That took more effort than I expected, but at least adb works now!