0% found this document useful (0 votes)
104 views

How To Setup Android SDK Without Android Studio

The document provides instructions for setting up the Android SDK without Android Studio using only the command line. It explains how to download the command line tools, set environment variables to locate the SDK, and use commands like sdkmanager and avdmanager to install SDK packages and create an Android Virtual Device (AVD) for emulator testing. It also describes how to configure the emulator for hardware-accelerated graphics and VM acceleration for improved performance.

Uploaded by

Favour Godspower
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views

How To Setup Android SDK Without Android Studio

The document provides instructions for setting up the Android SDK without Android Studio using only the command line. It explains how to download the command line tools, set environment variables to locate the SDK, and use commands like sdkmanager and avdmanager to install SDK packages and create an Android Virtual Device (AVD) for emulator testing. It also describes how to configure the emulator for hardware-accelerated graphics and VM acceleration for improved performance.

Uploaded by

Favour Godspower
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

How to setup Android SDK without Android Studio.

The foundation of android mobile development using any library is the “Android
SDK”. Android SDK is the prerequisite for building android apps, be it via native
Kotlin, or other popular libraries like React Native and Flutter.

Prerequisites

For this guide I assume you’ve already installed the Java JDK of your choice. I’d
suggest installing openjdk8, as it is prime choice for Android development, You can
install it via commands below.

 Download the Command Line Tools

Yes, Download, instead of directly installing them, I know this is a drag but just bear
with me.

Click on this link to visit the download page, then to the Command Line Tools Only
section, and Download the zip file according to you operating system (preferably
Linux OR Mac, If you are using windows, switch your OS).

Now after you’ve downloaded the zip file, move it to your home location i.e.

Now there’s another way to do this in one step, you can just copy the link to the zip
file, then open a terminal window and
For Windows:
Extract the contents to C:\Android\sdk

Navigate to C:\Android\sdk\tools\bin and open a command line window


(shift + right click)

Run the following to download the latest android package:


sdkmanager "platforms;android-25"

Update everything

sdkmanager --update

For those using the latest distribution on windows, the following should be enough:

1. Download the command line tools from here


2. Extract it somewhere (e.g. C:\Android\sdk\)
3. Add ANDROID_SDK_TOOLS as environment variable pointing to where you
extracted it (C:\Android\sdk\)
4. Create a folder named latest inside the cmdlime-tools you extracted. And
move what's inside(bin,lib...) to the folder latest.
5. Type cd cmdline-tools\latest\bin and execute the following:

sdkmanager --list
sdkmanager.bat system-images;android-29;default;x86_64
platforms;android-29 build-tools;29.0.3
extras;google;m2repository extras;android;m2repository

6. Agree to the terms and conditions and continue. Voilà

How to Set Up an Android Emulator using Command Line

To set up an Android emulator AKA Android Virtual Device (AVD):


(1) Download and install the Android SDK which comes bundled with Android
Studio .

(If you really want to use Command Prompt for this — it is


possible: https://superuser.com/questions/25538/how-to-download-
files-from-command-line-in-windows-like-wget-or-curl )

(2) After download and installation, the Android SDK can typically be found at C:\
Users\User\AppData\Local\Android\Sdk\ . You will have to add several sub-
folders to your environment PATH variable.
(3) Launch Command Prompt and add these directories to your
environment PATH variable with the following commands:

> PATH= %PATH%;C:\Users\User\AppData\Local\Android\Sdk\platform-


tools
> PATH= %PATH%;C:\Users\User\AppData\Local\Android\Sdk\emulator
> PATH= %PATH%;C:\Users\User\AppData\Local\Android\Sdk\tools\bin

(4) Install the latest SDK tools and system image for API level 28:

>sdkmanager "platform-tools" "platforms;android-28"


>sdkmanager "system-images;android-28;google_apis;x86"
>sdkmanager --licenses
>sdkmanager "platform-tools" "platforms;android-28" "build-
tools;27.0.3"

>sdkmanager
"extras;intel;Hardware_Accelerated_Execution_Manager"

(sdkmanager is dependent on the \tools\bin\ directory we added)

(5) Create an Android Virtual Device (AVD) using the following command:

> avdmanager create avd -n Android28 -k "system-images;android-


28;google_apis;x86"
Failed to run sdkmanager --list with Java 9
We are going to apply a fix in sdkmanager. It is a shell script. It is located
at $android_sdk\tools\bin, where $android_sdk is where you unzipped the
Android SDK.

1. Open sdkmanager in your favorite editor.


2. Locate the line which sets the DEFAULT_JVM_OPTS variable. In my copy, it is at
line 31:
3.DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
4. Append the following options to the variable: -XX:
+IgnoreUnrecognizedVMOptions --add-modules java.se.ee. Please
pay attention to the quotes. In my copy, the line becomes:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -
XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'

DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:
+IgnoreUnrecognizedVMOptions'

@rem Add default JVM options here. You can also use JAVA_OPTS
and SDKMANAGER_OPTS to pass JVM options to this script.
set JAVA_HOME="C:\ProgramData\scoop\apps\android-studio\current\
jre"
set DEFAULT_JVM_OPTS="-Dcom.android.sdklib.toolsdir=%~dp0\.."

Configure hardware acceleration for the Android Emulator


The Android Emulator can use hardware acceleration features to improve
performance, sometimes drastically. This page describes how you can configure
graphics and virtual machine (VM) acceleration to get higher performance from the
emulator.
Configure graphics acceleration
Graphics acceleration uses your computer's hardware (typically the GPU) to make
screen rendering faster. Android devices use OpenGL for Embedded Systems
(OpenGL ES or GLES) for rendering both 2D and 3D graphics on the screen.
When you create an Android Virtual Device (AVD) in the AVD Manager, you can
specify whether the emulator should use hardware or software to emulate the GPU
of the AVD. Hardware acceleration is recommended and is typically faster.
However, you might need to use software acceleration if your computer uses
graphics drivers that aren't compatible with the emulator. By default, the emulator
decides whether to use hardware or software graphics acceleration based on your
computer setup. If your GPU hardware and drivers are compatible, the emulator
uses the GPU. Otherwise, the emulator uses software acceleration (using your
computer's CPU) to simulate GPU processing.
Configure graphics acceleration from the command line

To specify a graphics acceleration type when you run an AVD from the command
line, include the -gpu option, as shown in the following example:

emulator -avd avd_name -gpu mode [{-option [value]} ... ]

The value of mode can be set to one of the following options:


 auto: Let the emulator choose between hardware or software graphics acceleration
based on your computer setup.
 host: Use the GPU on your computer for hardware acceleration. This option
typically provides the highest graphics quality and performance for the emulator.
However, if your graphics drivers have issues rendering OpenGL, you might need
to use the swiftshader_indirect or angle_indirect options.
 swiftshader_indirect: Use a Quick Boot-compatible variant of SwiftShader to
render graphics using software acceleration. This option is a good alternative
to host mode if your computer can't use hardware acceleration.
 angle_indirect: (Windows only) Use a Quick Boot-compatible variant
of ANGLE Direct3D to render graphics using software acceleration. This option is
a good alternative to host mode if your computer can't use hardware acceleration. In
most cases, ANGLE performance should be similar to using host mode because
ANGLE uses Microsoft DirectX instead of OpenGL. On Windows, Microsoft
DirectX drivers typically have fewer issues than OpenGL drivers. This option uses
Direct3D 11 and requires Windows 10, Windows 8.1, or Windows 7 SP1 with the
Windows 7 Platform Update.
 guest: Use guest-side software rendering. This option provides the lowest
graphics quality and performance for the emulator
Note: If you enable a graphics acceleration option that your computer doesn't
support, you are likely to see incorrect images displayed during emulation.

The following mode  options are deprecated:


 swiftshader: Deprecated in version 27.0.2Use swiftshader_indirect instead.

 angle: Deprecated in version 27.0.2. Use angle_indirect instead (Windows


only).
 mesa: Deprecated in version 25.3. Use swiftshader_indirect instead.

Enable Skia rendering for Android UI


When using images for API level 27 or higher, the emulator can render the Android
UI with Skia. Skia helps the emulator render graphics more smoothly and
efficiently.
To enable Skia rendering, use the following commands in adb shell:
su
setprop debug.hwui.renderer skiagl
stop
start

Configuring VM acceleration

VM acceleration uses your computer's processor to significantly improve the


execution speed of the emulator. A tool called a hypervisor manages this interaction
using virtualization extensions that your computer's processor provides. This
section outlines the requirements for using VM acceleration and describes how to
set up VM acceleration on each operating system.
General requirements
To use VM acceleration with the emulator, your computer must meet the general
requirements in this section. Your computer also needs to meet other requirements
that are specific to your operating system.

Development environment requirements


To use VM acceleration, your development environment must meet the following
requirements:
 SDK Tools: minimum version 17; recommended version 26.1.1 or later
 AVD with an x86-based system image, available for Android 2.3.3 (API level 10)
and higher
Warning: AVDs that use ARM- or MIPS-based system images can't use the VM
acceleration that is described on this page.
Virtualization extension requirements
In addition to the development environment requirements, your computer's
processor must support one of the following virtualization extensions technologies:
 Intel Virtualization Technology (VT, VT-x, vmx) extensions
 AMD Virtualization (AMD-V, SVM) extensions
Most modern processors support these virtualization extensions. If you're not sure
whether your processor supports these extensions, check the specifications for your
processor on the manufacturer's site. If your processor doesn't support one of these
extensions, then you can't use VM acceleration.
Note: Virtualization extensions are typically enabled through your computer BIOS
and are frequently turned off by default. Check the documentation for your
motherboard to find out how to enable virtualization extensions.
Restrictions
VM acceleration has the following restrictions:
 You can't run a VM-accelerated emulator inside another VM, such as a VM hosted
by VirtualBox, VMWare, or Docker. You must run a VM-accelerated emulator
directly on your host computer.
 Depending on your operating system and hypervisor, you can't run software that
uses another virtualization technology at the same time that you run a VM-
accelerated emulator. For example, VirtualBox, VMWare, and Docker currently use
a different virtualization technology, so you can't run them at the same time as the
accelerated emulator.
About hypervisors
VM acceleration requires a hypervisor.
Without a hypervisor and VM acceleration, the emulator must translate the machine
code from the VM block by block to conform to the architecture of the host
computer. This process can be quite slow. With a hypervisor, the VM and the
architecture of the host computer match, so the emulator can run code directly on
the host processor using the hypervisor. This improvement drastically increases
both the speed and performance of the emulator.
The hypervisor that will work best for you depends on your computer's operating
system and configuration. For more information, see one of the following sections:

You might also like