Skip to content

Most visited

Recently visited

navigation

Environment Variables

You can set environment variables for Android Studio and the command-line tools that specify things like where the SDK is installed and where user-specific data is stored. This page describes the most commonnly used environment variables.

The following example shows how to use an environment variable to launch an emulator when the SDK installation has been put in E:\Android\sdk\ instead of in its default location of $USER_HOME or $HOME.

$ set ANDROID_SDK_ROOT=E:\Android\sdk\
$ emulator -avd Pixel_API_25

Variables reference

The following table describes commonly used environment variables for the Android SDK tools.

Table 1. Environment variables

Android SDK environment variables
ANDROID_SDK_ROOT Sets the path to the SDK installation directory. Once set, the value does not typically change, and can be shared by multiple users on the same machine. ANDROID_HOME, which also points to the SDK installation directory, is deprecated. If you continue to use it, the following rules apply:
  • If ANDROID_HOME is defined and contains a valid SDK installation, it's value is used instead of the value in ANDROID_SDK_ROOT.
  • If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used.
  • If ANDROID_HOME is defined but, does not exist or does not contain a valid SDK installation, the value in ANDROID_SDK_ROOT is used instead.
REPO_OS_OVERRIDE Set this variable to windows, macosx, or linux when you use sdkmanager to download packages for an operating system different from the current machine.
Android Studio configuration environment variables
The Android Studio configuration variables contain settings that customize the location of configuration files and the JDK. On start-up, Android Studio checks these variables for settings. For more information, see Configure Android Studio.
STUDIO_VM_OPTIONS Sets the location of the studio.vmoptions file. This file contains settings that affect the performance characteristics of the Java HotSpot Virtual Machine. This file can also be accessed from within Android Studio. See Customize your VM options.
STUDIO_PROPERTIES Sets the location of the idea.properties file. This file allows you to customize Android Studio IDE properties, such as the path to user installed plugins, and the maximum file size supported by the IDE. See Customize your IDE properties.
STUDIO_JDK Sets the location of the JDK with which to run Studio. When you launch Android Studio, it checks the STUDIO_JDK, JDK_HOME, and JAVA_HOME environment variables in that order.
Emulator Environment Variables
By default, the emulator stores configuration files under $HOME/.android/ and AVD data under $HOME/.android/avd/. You can override the defaults by setting the following environment variables. The emulator -avd <avd_name> command searches the avd directory in the order of the values in $ANDROID_AVD_HOME, $ANDROID_SDK_HOME/.android/avd/, and $HOME/.android/avd/.

For emulator environment variable help, type emulator -help-environment at the command line. For information about emulator command-line options, see Control the Emulator from the Command Line.

ANDROID_EMULATOR_HOME Sets the path to the user-specific emulator configuration directory. The default location is $ANDROID_SDK_HOME/.android/.
ANDROID_AVD_HOME Sets the path to the directory that contains all AVD-specific files, which mostly consist of very large disk images. The default location is $ANDROID_EMULATOR_HOME/avd/. You might want to specify a new location if the default location is low on disk space.
The Android emulator queries the following environment variables when it starts.
ANDROID_LOG_TAGS See ANDROID_LOG_TAGS.
HTTP_PROXY Contains the HTTP/HTTPS proxy (host name and port) setting for a global http proxy. Uses a colon (:) separator between the host and the port. For example, set HTTP_PROXY=myserver:1981.
ANDROID_VERBOSE See ANDROID_VERBOSE.
ANDROID_EMULATOR_HOME See ANDROID_EMULATOR_HOME.
ANDROID_SDK_ROOT See ANDROID_SDK_ROOT.
ANDROID_EMULATOR_USE_SYSTEM_LIBS Contains a value of 0 (default) or 1. A value of 1 means to use the system's libstdc++.so file instead of the one that comes bundled with the emulator. Set this enivronment variable only when the emulator does not start on your linux system because of a system library problem. For example, some Linux Radeon GL driver libraries require a more recent libstdc++.so file.
Quick emulator (QEMU) audio
QEMU_AUDIO_DRV QEMU_AUDIO_OUT_DRV QEMU_AUDIO_IN_DRV On Linux, you can change the default audio backend of the emulator by setting the QEMU_AUDIO_DRV environment variable to one of the following values:
  • alsa: Use the Advanced Linux Sound Architecture (ALSA) backend
  • esd: Use the Enlightened Sound Daemon (EsounD) backend
  • sdl: Use the Simple DirectMedia Layer (SDL) audio backend (no audio input supported)
  • oss:: Use the Open Sound System (OSS) backend
  • none:: Do not support audio
set QEMU_AUDIO_DRV=alsa

You can also use distinct backends for audio input and audio outputs by selecting one of the QEMU values for the QEMU_AUDIO_OUT_DRV and QEMU_AUDIO_IN_DRV environment variables:

set QEMU_AUDIO_OUT=esd
set QEMU_AUDIO_IN=oss

If you want to disable the audio support, use the emulator -no-audio option or set QEMU_AUDIO_DRV to none. You might need to disable the audio in the following situations:

  • In rare cases, audio drivers can cause Windows to reboot while the emulator is running.
  • On some Linux machines, the emulator might get stuck at startup with audio support enabled.
adb environment variables
ANDROID_SERIAL Use this variable to provide an emulator serial number, such as emulator-5555, to an adb command. If you set this variable, but use the -s option to specify a serial number from the command line, the command-line input overrides the value in ANDROID_SERIAL.

The following example sets ANDROID_SERIAL and calls adb install helloworld.apk, which then installs the Android application package on emulator-5555.

set ANDROID_SERIAL=emulator-555
adb install helloWorld.apk
adb logcat environment variables
ANDROID_LOG_TAGS Use this environment variable to set a default filter expression when you are running logcat from your development computer. For example:
set ANDROID_LOG_TAGS=ActivityManager:I MyApp:D *:.

See Filtering Log Output for more information and examples.

ADB_TRACE Contains a comma-separated list of the debug information to log. Values can be the following: all, adb, sockets, packets, rwx, usb, sync, sysdeps, transport, and jdwp.

To display the adb logs for the adb clients and the adb server, set ADB_TRACE to all, and then call the adb logcat command, as follows:

set ADB_TRACE=all
adb logcat
ANDROID_VERBOSE Contains a comma-separated list of verbose output options (debug tags) used by the emulator. The following example shows ANDROID_VERBOSE defined with the debug-socket and debug-radio debug tags:
set ANDROID_VERBOSE=socket,radio

Unsupported debug tags are ignored. For more information about debug tags, use emulator -help-debug-tags.

Hierarchy Viewer
ANDROID_HVPROTO If your device is running Android 4.1 (API Level 16) or newer, set ANDROID_HVPROTO with a value of ddm and restart the adb server so you can use Hierarchy Viewer to review and troubleshoot your layouts. For more information about Hierarchy Viewer, see Optimizing Your UI.

How to set environment variables

The following examples show how to set environment variables in a terminal window and in a shell script for different operating systems. Variable settings in terminal windows last as long as the window is open. Variable settings in shell scripts persist across login sessions.

Windows: In a terminal window, type the following:

set HTTP_PROXY=myserver:1981

Alternately, add it to a shell script through the Windows UI. Check the documentation for your version of Windows to learn how.

Mac and Linux: In a terminal window, type the following:

export HTTP_PROXY=myserver:1981

Alternately, add it to your ~/.bash_profile file and source the file as follows:

export HTTP_PROXY=myserver:1981
$ source ~/.bash_profile
This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a one-minute survey?
Help us improve Android tools and documentation.