This tutorial covers basic Android SDK setup for Windows 11 so you can work either from Android Studio IDE or the cmd line.

For some simple tasks you might not want to run Android Studio every single time.

If you don’t want to deal with Android Studio at all, you can install the SDK manually.

Install Java

I prefer the Oracle version JDK, but OpenJDK will work too.

Configure JAVA_HOME environment variable. If you’ve installed oracle jdk17, JAVA_HOME should equal:

C:\Program Files\Java\jdk-17

Setting JAVA_HOME helps in ensuring that Java-based applications and development tools use the correct version of Java, especially when multiple versions are installed on the same machine.

Download Android Studio

Go to the Android Developer website to download Android Studio. I prefer to use the jetbrains tools since I use other jetbrains products.

Configure Android Studio

When you run the studio for the first time it will do most of the heavy lifting for you. This includes downloading the Android SDK and any other necessary development tools. If offered at first run, select the Command Line Tools too. If not, you can choose it by going to Tools -> SDK Manager.

Configure environment variables

For ease of use, set up environment variables on your Windows machine.

ANDROID_HOME - C:\Users\<username>\AppData\Local\Android\Sdk

Add to path:

C:\Users\<username>\AppData\Local\Android\Sdk

C:\Users\<username>\AppData\Local\Android\Sdk\platform-tools

C:\Users\<username>\AppData\Local\Android\Sdk\cmdline-tools\latest\bin

Useful tools

When debugging your app you’ll want to take a peek at logs from your real device or emulator. Without the e argument there’ll be too much noise:

adb logcat -e your.package

Create an avd:

avdmanager.bat create avd -n testDevice -k "system-images;android-34;google_apis;x86_64"

Run emulator:

emulator -avd testDevice

Downgrade platform/build tools version:

sdkmanager --licenses 
sdkmanager "platform-tools" "platforms;android-30" "build-tools;30.0.3"

By using cmdline tools you don’t need to have or run Android studio at all: download different sdk versions, create avds, run emulator…all that from the terminal.

It’s a little bit more user friendlier when running these tasks from studio.

Categories: Uncategorized

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *