You can configure the behavior of Android Studio and the command-line tools by setting
environment variables. One of the most useful environment variables to set is
[`ANDROID_HOME`](https://developer.android.com/tools/variables#android_home), which many tools read to
determine the Android SDK installation directory.

To run tools from the command line without including the full path to the executable,
set your command
search path environment variable to include
<var translate="no">ANDROID_HOME</var>`/tools`, <var translate="no">ANDROID_HOME</var>`/tools/bin`, and
<var translate="no">ANDROID_HOME</var>`/platform-tools`.

## 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
only as long as the window is open. On macOS and Linux, each time a new shell starts, variable
settings are set
in shell
initialization scripts. On Windows, variable settings can be
set through the system settings.

**Windows:** In a terminal window, type the following:

```
set HTTP_PROXY=myserver:1981
```


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

**macOS and Linux:** The precise method of setting environment variables depends on
which shell you are using. To determine which shell type is running, type the following:  

```
echo $0
```


In shells such as
[Gnu Bash](https://www.gnu.org/software/bash/) or
[Zsh](https://zsh.org), variables are set using the following
syntax:  

```
export VARIABLE_NAME=<new-value>
```


In other shells, such as
[TCSH](https://www.tcsh.org/), variables are set using the
following syntax:  

```
setenv VARIABLE_NAME <new-value>
```


These commands can be added to the shell initialization script to set the variables each time a
new shell instance is run.


The location of the shell initialization script depends on the shell being used.
For Gnu Bash, the location can be `~/.bash_profile`. For
Zsh, the location can be `~/.zprofile`. For TCSH, the location can be
`~/.cshrc`. Check
the documentation for the shell that you're using to be sure.


You can also update the `PATH` environment variable to include the tool locations.


For Gnu Bash or Zsh:  

```
export ANDROID_HOME=~/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
  
```


And for TCSH:  

```
setenv ANDROID_HOME ~/Library/Android/sdk
setenv PATH $PATH\:$ANDROID_HOME/tools\:$ANDROID_HOME/tools/bin\:$ANDROID_HOME/platform-tools
  
```

## Variables reference


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

**Table 1.** Environment variables

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Android SDK environment variables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ||
|-----------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ANDROID_HOME`                                            | 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_SDK_ROOT`, which also points to the SDK installation directory, is deprecated. If you continue to use it, Android Studio and the Android Gradle plugin will check that the old and new variables are consistent.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `ANDROID_USER_HOME`                                       | Sets the path to the user preferences directory for tools that are part of the Android SDK. Defaults to `$HOME/.android/`. Some older tools, such as Android Studio 4.3 and earlier, do not read `ANDROID_USER_HOME`. To override the user preferences location for those older tools, set `ANDROID_SDK_HOME` to the parent directory you would like the `.android` directory to be created under.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| `REPO_OS_OVERRIDE`                                        | Set this variable to `windows`, `macosx`, or `linux` when you use [`sdkmanager`](https://developer.android.com/studio/command-line/sdkmanager) to download packages for an operating system different from the current machine. | **Note:** You can use Android Studio instead of `sdkmanager` to manage your SDK packages. See [Update your | tools with the SDK Manager](https://developer.android.com/studio/intro/update#sdk-manager).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| The Android Studio configuration variables contain settings that customize the location of configuration files and the JDK. On startup, Android Studio checks these variables for settings. For more information, see [Configure Android Studio](https://developer.android.com/studio/intro/studio-config).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     ||
| `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](https://developer.android.com/studio/intro/studio-config#customize_vm).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `STUDIO_PROPERTIES`                                       | Sets the location of the `idea.properties` file. This file lets you 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](https://developer.android.com/studio/intro/studio-config#customize_ide).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `STUDIO_JDK`                                              | Sets the location of the JDK that Android Studio runs in. When you launch the IDE, it checks the `STUDIO_JDK`, `JDK_HOME`, and `JAVA_HOME` environment variables, in that order.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `STUDIO_GRADLE_JDK`                                       | Sets the location of the JDK that Android Studio uses to start the Gradle daemon. When you launch the IDE, it first checks `STUDIO_GRADLE_JDK`. If `STUDIO_GRADLE_JDK` is not defined, the IDE uses the value set in the [project structure settings](https://developer.android.com/studio/projects#ProjectStructure).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| 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_USER_HOME/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 [Start the emulator from the command line](https://developer.android.com/studio/run/emulator-commandline).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           ||
| `ANDROID_EMULATOR_HOME`                                   | Sets the path to the user-specific emulator configuration directory. Defaults to `$ANDROID_USER_HOME`. Older tools, such as Android Studio 4.3 and earlier, do not read `ANDROID_USER_HOME`. For those tools, the default value 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`](https://developer.android.com/tools/variables#android_log_tags).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `HTTP_PROXY`                                              | Contains the HTTP/HTTPS proxy setting for a global HTTP proxy. Uses a colon (:) separator between the host and the port. For example, `set HTTP_PROXY=myserver:1981`. This is the same as specifying the [`-http-proxy `*proxy*` `](https://developer.android.com/studio/run/emulator-commandline#startup-options) argument when running the emulator from the command line.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `ANDROID_VERBOSE`                                         | See [`ANDROID_VERBOSE`](https://developer.android.com/tools/variables#android_verbose).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| `ANDROID_HOME`                                            | See [`ANDROID_HOME`](https://developer.android.com/tools/variables#android_home).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `ANDROID_EMULATOR_USE_SYSTEM_LIBS`                        | Contains a value of 0 (default) or 1. A value of 1 means the system's `libstdc++.so` file is used instead of the one that comes bundled with the emulator. Set this environment 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. | **Note:** There is no guarantee that setting this environment variable to 1 will make the emulator runnable. It is a work-around for system library issues that affect a very small number of Linux users.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `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. |
| `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 ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `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 *:. This is the same as specifying the [`-logcat `*tags*](https://developer.android.com/studio/run/emulator-commandline#startup-options) argument when running the emulator from the command line. See [Filter log output](https://developer.android.com/studio/command-line/logcat#filteringOutput) 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 ``` This is the same as specifying the `-verbose -verbose-socket -verbose-radio` arguments together when running the emulator from the command line. Unsupported debug tags are ignored. For more information about debug tags, use ` emulator -help-debug-tags`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |