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.
Once downloaded, extract the compressed.
Download and install JDK 17. You can pick the binary from AdoptOpenJDK or install it using Winget, included by default in Windows.
I'm gonna use Winget,. To install OpenJDK with it just write the following in the terminal:
winget install Microsoft.OpenJDK.17
Create a directory under C:\
named Dev
and another called android
inside. Place both, cmdline-tools
and platform-tools
into C:\Dev\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
Note: is important to create a folder with the cmdline-tools, otherwise you'll get an error when the sdkmanager command is used.
Check the version number and create a folder named with it. Once created, move all the content of the cmdline-tools
insto this new folder. At the end, you will have the following folder structure:
C:\Dev\android\cmdline-tools\[cmdline-tools version]
C:\Dev\android\platform-tools
Android requires some environment variables in order to find the installation directory in internal processes.
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 the directory is the one above:
C:\Program Files\Microsoft\jdk-17.0.15.6-hotspot
ANDROID_HOME
This must contain the address of the folder containing the cmdline-tools
. So it must be:
C:\Dev\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
Save changes.
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 36.0.0
, but I'm gonna install the last version of 35.x (35.0.1
):
sdkmanager "build-tools;35.0.1"
Now we can install the Android APIs we want. So, let's install the Android 35 API level (Android 15).
We can get the name from the sdkmanager --list
previously executed.
sdkmanager "platforms;android-35"
We have installed Android 35 API, commercially named Android 15. 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-35;google_apis_playstore;x86_64
image:
# if you want android with play store
sdkmanager "system-images;android-35;google_apis_playstore;x86_64"
# otherwise, install the classic one
sdkmanager "system-images;android-35;google_apis;x86_64"
We have almost everything 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 (optional)
There is a very important step to do if you have an intel CPU. If that's the case, you need to install HAXM (Hardware acceleration for Intel).
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 35. This is the command that will do it:
avdmanager create avd --name "Pixel_Android_15" --device "pixel" --package "system-images;android-35;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_Android_15" # here "Pixel_Android_15" is the name I set to my emulator
Congratulations, you're ready to install your favorite hybrid framework and start making great apps!
thank you very much for the guide.
you are much appreciated.