Explains all the steps required to install Android SDK Tools on Windows without using Android Studio.

How To Install Android SDK Tools On Windows
How To Install Android SDK Tools On Windows
March 10, 2019

In this post, we will discuss the steps required to install Android SDK Tools on Windows. It assumes that JDK 8 or lower is installed on the system to work out of the box since JDK 9, 10, and 11 have reported compatibility issues with Android SDK. There are solutions suggested by the community to work with JDK 9, 10 and 11 as shown at the end of this post.

This post is useful for the developers using Android SDK Tools with other IDEs without installing Android Studio for the use cases including hybrid app development using Ionic. It also assumes that a valid JAVA_HOME environment variable exists pointing to the installation directory of Java.

Download SDK Tools

Open the download link of Android SDK Tools. The download page will show various options to download the SDK tools as shown in Fig 1.

Download Android SDK Tools

Fig 1

Click on the first link having the download option for Windows. It will ask to accept to terms and conditions as shown in Fig 2.

Terms and Conditions

Fig 2

Go through the details, agree on the terms and conditions and click on the Download Button to start the download.

Install SDK Tools

Create a directory having name set to android-sdk and copy the downloaded SDK Tools zip to this directory. Now extract the tools.

Install Platform Tools

Follow the same steps similar to Android SDK Tools to install Android Platform Tools using the download link.

Configure Environment Variable

Right click on the My Computer on the desktop and click on Properties option. Click on Advanced system settings. It will show the System Properties dialog having Advanced Tab open as shown in Fig 3.

Advanced System Settings

Fig 3

Click on Environment Variables Button and click on New Button on the first section. Set the Variable Name field to ANDROID_HOME and Variable Value to the android-sdk directory created by us in the previous step.

Similarly, also configure the environment variable ANDROID_SDK_ROOT to the android-sdk directory.

Configure Commands

In previous steps, we have downloaded and extracted the SDK Tools and Platform Tools to the android-sdk directory. Both the tools provide several command line utilities which we need to run by going to the appropriate directory having the executable files.

We can make these commands available at system level without going to these directories by adding the path to tools, tools\bin, and platform-tools to system path as shown in Fig 4. Make sure that these executables do not break other commands having the same name before adding these paths to the PATH environment variable.

System Path

Fig 4

Now restart the system to apply the environment variables set by us.

# Check adb version
adb --version

# It must show the installed adb version
Android Debug Bridge version 1.0.40
Version 4986621
Installed as <path to android-sdk>\platform-tools\adb.exe


# Check sdkmanager version
sdkmanager --version

# It must shown installed sdkmanager version
26.1.1

Using the SDK Manager

List - We can list the installed and available packages and images using list command as shown below.

// List all the installed and available platforms, system images and other resources 
sdkmanager --list

// Output should look like
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
platform-tools | 28.0.1 | Android SDK Platform-Tools 28.0.1 | platform-tools\
tools | 26.1.1 | Android SDK Tools 26.1.1 | tools\

Available Packages:
...
...

// We can see that it shows the tools and platform-tools installed by us

Install Platform - Use the below-mentioned command to install the Android 9 (API level 28) using the SDK manager.

# Go to the SDK Tools bin directory to access sdkmanager
# Start download the most recent package
sdkmanager "platforms;android-28"

It will ask to accept the terms and conditions. Enter y and hit Enter Key to accept the terms and conditions. This command creates the directory platforms within android-sdk and installs the package android-28 having all the required files to run the emulator for Android 9.

If we again check the installed packages, the list commands show the installed options as shown below.

sdkmanager --list
Installed packages:=====================] 100% Computing updates...
Path | Version | Description | Location
------- | ------- | ------- | -------
platform-tools | 28.0.1 | Android SDK Platform-Tools 28.0.1 | platform-tools\
platforms;android-28 | 6 | Android SDK Platform 28 | platforms\android-28\
tools | 26.1.1 | Android SDK Tools 26.1.1 | tools\

Available Packages:
...
...

Update SDK Manager - Update the SDK manager using the below-mentioned command.

sdkmanager --update

Add System Image - We can add system image from available images shown by list command using the SDK manager as shown below. We are adding the most recent default 64-bit system image.

// Install default system image for platform android-28
sdkmanager "system-images;android-28;default;x86_64"

Accept the License Agreement to complete the download.

There are several projects which need Google Play Services. We need system images specific to Google Play Services as shown below.

// Install Google Play Services system image
sdkmanager "system-images;android-28;google_apis_playstore;x86_64"

Install Emulator - We need to install the emulator before creating the AVD using SDK Manager.

// Install Emulator
sdkmanager --channel=3 emulator

Install Build Tools - Install the most recent build tool listed by list command.

// Install Build Tools
sdkmanager "<build tools version>"

// Example
sdkmanager "build-tools;28.0.3"

Using the Emulator and AVD Manager

Create Android Emulator - Create the emulator using the system image downloaded in the previous step as shown below. Replace <emulator name> with actual name.

// Create the emulator using default system image
avdmanager create avd -n <emulator name> -k "system-images;android-28;default;x86_64" -g "default"

// Create emulator using Google Play Services system image
avdmanager create avd -n <emulator name> -k "system-images;android-28;google_apis_playstore;x86_64"

The above commands ask a bunch of question to configure the AVD if we choose the custom hardware profile option. We have excluded the details of these options from this tutorial since these configuration details depend on the actual needs. After completing all the configurations, it creates the AVD using the name provided by us while configuring it.

List Android Emulators - Now go to the tools directory on the command line and check the installed platform as shown below.

// List the available emulators
emulator -list-avds

It will list all the AVDs installed by us.

Run Emulator - We can run the emulator created by us as shown below.

// Run Emulator
emulator -avd <emulator name>

The above command might show an error specific to the qt library. We can execute the emulator from the Android SDK Tools directory in such case.

The emulator will take some time to completely launch the AVD. The final results should look similar to the one shown in Fig 5.

Android Emulator

Fig 5

Delete Emulator - We can also delete an existing emulator as shown below.

// Delete Emulator
avdmanager delete avd -n <emulator name>

Working with JDK 9 or above

Use the below-mentioned command for JDK 9 and 10 on Linux and Windows.

// Linux/Mac
export JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

// Windows
set JAVA_OPTS='-XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

Modifying the SDK manager script is another option as shown below.

// Replace this
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'

// With
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

We need to download additional jars(JAXB, JAF) and modify the SDK manager script - sdkmanager.bat for Java 11 as shown below.

set CLASSPATH=jaxb-core.jar;jaxb-impl.jar;jaxb-api.jar;activation.jar

Write a Comment

Click on the captcha image to get new code.
Discussion Forum by DISQUS