If you are a React Native, NativeScript, Flutter or Ionic developer maybe you don't want to install the entire Android Studio just to have your environment ready. If this is your case, this guide will help you to setup your minimal Android SDK environment in Windows.
First of all, we need to download the following stuff.
- Android command-line tools
- Android platform tools
Once downloaded, extract the compressed.
Download and install JDK 17. You can pick the binary from AdoptOpenJDK or install it using chocolatey.
To install JDK using chocolatey, just write the following in the terminal:
choco install microsoft-openjdk17
Create a directory under C:\
named Development
and another called android
inside. Place both, cmdline-tools
and platform-tools
into C:\Development\android
.
Once folders are copied, enter to cmdline-tools
and open the source.properties
file. You will see something like this:
Pkg.Revision=4.0
Pkg.Path=cmdline-tools;4.0
Pkg.Desc=Android SDK Command-line Tools
Check the version number and create a folder named with it. Once created, copy all the content of the cmdline-tools
to this new folder.
At the end, you will have the following folder structure.
C:\Development\android\cmdline-tools\[cmdline-tools version]
C:\Development\android\platform-tools
Android requires some environment variables in order to find the installation directory in internal processes. So, let's create them (I will not cover how to do this).
Note: set the environment variables in the System Variables section.
JAVA_HOME
The first environment variable we need to set is JAVA_HOME. Here you need to copy the installation directory of JDK. In my case it is:
C:\Program Files\AdoptOpenJDK\jdk-8.0.292.10-hotspot
ANDROID_HOME
This must contain the address of the folder containing the cmdline-tools
. So it must be:
C:\Development\android
ANDROID_SDK_ROOT
The value for this variable is the same we used for ANDROID_HOME
.
Now, edit the path
variable and add the following values:
%JAVA_HOME%\bin
%ANDROID_HOME%\cmdline-tools\4.0\bin
%ANDROID_HOME%\platform-tools
Accept changes and restart the OS.
We have the tools installed and configured. But this isn't enough because we need to install Android APIs (OS versions) and create emulators for our purposes.
Before install them, we have to install the build-tools
. So, to know which is
the last version, run the following command:
sdkmanager --list
You'll see some build-tools
versions. Pick the last stable (not RC). The last
one currently is the 30.0.3
. So, install it:
sdkmanager "build-tools;30.0.3"
Now we can install the Android APIs we want. So, let's install the Android 34 API level (Android 14).
We can get the name from the sdkmanager --list
previously executed.
sdkmanager "platforms;android-34"
We have installed Android 34 API, commercially named Android 14. Now we can install
some Android images. An Android image is just a operating system built
under an Android API. So, to see what images we have available, execute sdkmanager --list
again.
I gonna install system-images;android-34;google_apis_playstore;x86_64
image:
# if you want android with play store
sdkmanager "system-images;android-34;google_apis_playstore;x86_64"
# otherwise, install the classic one
sdkmanager "system-images;android-34;google_apis;x86_64"
and we're done.
We have almost anything to start working: Java, Android SDK, Android APIs and Android images. The final step to complete our environment is create emulators.
Install emulator
Before all, we need to install the emulator component through this command:
sdkmanager --channel=0 emulator
Note: channel 0 means stable release.
After that, go to environment variables on Windows and add, to the path
variable
the following:
%ANDROID_HOME%\emulator
Save changes.
Install Hardware Acceleration Execution Manager (opcional)
There is a very important step to do if you have an intel processor. We need to install HAXM (Hardware acceleration for Intel). So, place into the terminal and run this command:
sdkmanager "extras;intel;Hardware_Accelerated_Execution_Manager"
After installed, go to C:\Development\android\extra\intel\Hardware Accelerated Execution Manager
and execute the installer. Go through the wizard and you are done.
Create virtual devices
Run avdmanager list
to get all available system images. You will get a list like this:
id: 0 or "tv_1080p"
Name: Android TV (1080p)
OEM : Google
Tag : android-tv
---------
id: 1 or "tv_720p"
Name: Android TV (720p)
OEM : Google
Tag : android-tv
---------
id: 2 or "automotive_1024p_landscape"
Name: Automotive (1024p landscape)
OEM : Google
Tag : android-automotive-playstore
---------
...more images
Note that each item has a name. This is useful to tell avdmanager which device you want. For example, I want to create an emulator in a Pixel device with google apis and Android 34. This is the command that will do it:
avdmanager create avd --name "Pixel" --device "pixel" --package "system-images;android-34;google_apis;x86_64" --tag "google_apis" --abi "x86_64"
Note that --device
is the name of the device we pick from list. The --package
argument
tells what system image we want to use. The --tag
argument tells we want to use "google-apis"
or "generic", and --abi
is the architecture we want.
This process is almost instantly. So, after run the command you will able to run the emulator you have created:
emulator -avd "Pixel" # here "Pixel" is the name I set to my emulator
Congratulations, you're ready to install your favorite hybrid framework and start making great apps!