You are on page 1of 8

Android Developers

Congure Android Studio


Android Studio provides wizards and
templates that verify your system
requirements, such as the Java
Development Kit (JDK) and available RAM,
and congure default settings, such as an
optimized default Android Virtual Device
(AVD) emulation and updated system
images. This document describes
additional conguration settings you may
want to use to customize your use of
Android Studio.

In this document
Find your conguration les
Customize your VM options
Maximum heap size
Customize your IDE
properties
Set the JDK version
Set proxy settings

Android Studio provides access to two


conguration les through the Help menu:
studio.vmoptions

Set up the Android Studio


proxy
Android Plugin for Gradle
HTTP proxy settings

(#customize_vm):

Customize options for Studio's Java Virtual


Machine (JVM), such as heap size and
cache size. Note that on Linux machines this le may be named
studio64.vmoptions, depending on your version of Android Studio.
idea.properties

(#customize_ide):

Customize Android Studio properties, such

as the plugins folder path or maximum supported le size.


For specic documentation about emulator and device setup and use, see
Managing Virtual Devices (https://developer.android.com/tools/devices/index.html), Using
Hardware Devices (https://developer.android.com/tools/device.html), and OEM USB Drivers
(https://developer.android.com/tools/extras/oem-usb.html).

Find your conguration les


Both conguration les are stored in the conguration folder for Android Studio.
The name of the folder depends on your Studio version. For example, Android
Studio 2.2 has the folder name AndroidStudio2.2. The location of this folder
depends on your operating system:

Windows: %USERPROFILE%\.<CONFIGURATION_FOLDER>/
Mac: ~/Library/Preferences/<CONFIGURATION_FOLDER>/
Linux: ~/.<CONFIGURATION_FOLDER>/
You can also use the following environment variables to point to specic override
les elsewhere:
STUDIO_VM_OPTIONS: set the name and location of the .vmoptions le
STUDIO_PROPERTIES: set the name and location of the .properties le
STUDIO_JDK: set the JDK with which to run Studio

Customize your VM options


The studio.vmoptions le allows you to customize options for Android Studio's
JVM. To improve Studio's performance, the most common option to adjust is the
maximum heap size, but you can also use the studio.vmoptions le to override
other default settings such as initial heap size, cache size, and Java garbage
collection switches.
To create a new studio.vmoptions le or to open your existing one, use the
following steps:
1. Click Help > Edit Custom VM Options. If you have never edited VM options for
Android Studio before, the IDE prompts you to create a new studio.vmoptions
le. Click Yes to create the le.
2. The studio.vmoptions le opens in the editor window of Android Studio. Edit
the le to add your own customized VM options. For a full list of customizable
JVM options, see Oracle's Java HotSpot VM Options page (http://www.oracle.com
/technetwork/java/javase/tech/vmoptions-jsp-140102.html).

The studio.vmoptions le you create gets added to the default


studio.vmoptions le, located in the bin/ directory inside your Android Studio

installation folder.
Note that you should never directly edit the studio.vmoptions le found inside the
Android Studio program folder. While you can access the le to view Studio's
default VM options, editing only your own studio.vmoptions le ensures that you
don't override important default settings for Android Studio. Therefore, in your
studio.vmoptions le, override only the attributes you care about and allow

Android Studio to continue using default values for any attributes you have not
changed.

Maximum heap size


By default, Android Studio has a maximum heap size of 1280MB. If you are working
on a large project, or your system has a lot of RAM, you can improve performance
by increasing the maximum heap size in the VM options for Android Studio.
To increase the maximum heap size, follow these steps:
1. Click Help > Edit Custom VM Options to open your studio.vmoptions le.
2. Add a line to the studio.vmoptions le to set maximum heap size using the
syntax -XmxheapSize. The size you choose should be based on the size of your
project and the available RAM on your machine. As a baseline, if you have more
than 4GB of RAM and a medium-sized project, you should set the maximum
heap size to 2GB or more. The following line sets the maximum heap size to
2GB:
-XXmmxx22gg

3. Save your changes to the studio.vmoptions le, and restart Android Studio for
your changes to take effect.
4. To conrm your new maximum heap size, open the command line, and type the
following command:
jps -lvm

You will see a list of the instrumented JVMs running on your machine, including
the full package name for each and the arguments passed in. Locate the item
corresponding to your instance of Android Studio. It should end with
-Didea.paths.selector=AndroidStudio[Version]. You should see two

arguments beginning with -Xmx for this JVM, one with the default value of
1280mb, and one with your new value, as shown in gure 1.

Figure 1. The terminal output showing the current arguments for Android Studio's JVM.

The -Xmx argument showing the default maximum heap size, in this case
1280m.
The -Didea.paths.selector showing the version of Android Studio
currently running.
The -Xmx argument showing the new custom maximum heap size. Note
that this is followed by the location the custom studio.vmoptions le
you created above.

Customize your IDE properties


The idea.properties le allows you to customize IDE properties for Android
Studio, such as the path to user installed plugins and the maximum le size
supported by the IDE. The idea.properties le gets merged with the default
properties for the IDE so you can specify just the override properties.
To create a new idea.properties le or to open your existing le, use the
following steps:
1. Click Help > Edit Custom Properties. If you have never edited the IDE properties
before, Android Studio prompts you to create a new idea.properties le. Click
Yes to create the le.
2. The idea.properties le opens in the editor window of Android Studio. Edit the
le to add your own customized IDE properties.
The following idea.properties le includes the commonly customized IDE
properties. For a complete list of properties, read about the idea.properties le
for IntelliJ IDEA (https://www.jetbrains.com/help/idea/2016.2/le-idea- properties.html).

#--------------------------------------------------------------------# Uncomment this option if you want to customize path to user installed p
# you're using forward slashes.
#--------------------------------------------------------------------# idea.plugins.path=${idea.config.path}/plugins
#--------------------------------------------------------------------# Maximum file size (kilobytes) IDE should provide code assistance for.
# The larger file is the slower its editor works and higher overall syste
# if code assistance is enabled. Remove this property or set to very larg
# code assistance for any files available regardless their size.
#--------------------------------------------------------------------idea.max.intellisense.filesize=2500
#---------------------------------------------------------------------

# This option controls console cyclic buffer: keeps the console output si
# specified buffer size (Kb). Older lines are deleted. In order to disabl
# idea.cycle.buffer.size=disabled
#--------------------------------------------------------------------idea.cycle.buffer.size=1024
#--------------------------------------------------------------------# Configure if a special launcher should be used when running processes f
# Using Launcher enables "soft exit" and "thread dump" features
#--------------------------------------------------------------------idea.nnoo.launcher=ffaallssee
#--------------------------------------------------------------------# To avoid too long classpath
#--------------------------------------------------------------------idea.ddyynnaammiicc.classpath=ffaallssee
#--------------------------------------------------------------------# There are two possible values of idea.popup.weight property: "heavy" an
# If you have WM configured as "Focus follows mouse with Auto Raise" then
# set this property to "medium". It prevents problems with popup menus on
# configurations.
#--------------------------------------------------------------------idea.popup.weight=heavy
#--------------------------------------------------------------------# Use default anti-aliasing in system, i.e. override value of
# "Settings|Editor|Appearance|Use anti-aliased font" option. May be usefu
# Remote Desktop Connection for instance.
#--------------------------------------------------------------------idea.uussee.ddeeffaauulltt.antialiasing.iinn.editor=ffaallssee
#--------------------------------------------------------------------# Disabling this property may lead to visual glitches like blinking and f
# on certain display adapter cards.
#--------------------------------------------------------------------sun.java2d.noddraw=ttrruuee
#--------------------------------------------------------------------# Removing this property may lead to editor performance degradation under
#--------------------------------------------------------------------sun.java2d.d3d=ffaallssee
#--------------------------------------------------------------------# Workaround for slow scrolling in JDK6
#--------------------------------------------------------------------swing.bufferPerWindow=ffaallssee
#--------------------------------------------------------------------# Removing this property may lead to editor performance degradation under
#--------------------------------------------------------------------sun.java2d.pmoffscreen=ffaallssee
#--------------------------------------------------------------------# Workaround to avoid long hangs while accessing clipboard under Mac OS X
#--------------------------------------------------------------------# ide.mac.useNativeClipboard=True
#--------------------------------------------------------------------# Maximum size (kilobytes) IDEA will load for showing past file contents
# in Show Diff or when calculating Digest Diff
#--------------------------------------------------------------------# idea.max.vcs.loaded.size.kb=20480

Set the JDK version


A copy of the latest OpenJDK comes bundled with Android Studio 2.2 and higher,
and this is the JDK version we recommend you use for your Android projects. To
use the bundled JDK, proceed as follows:
1. Open your project in Android Studio and select File > Project Structure in the
menu bar.
2. In the SDK Location page and under JDK location, check the Use embedded JDK
checkbox.
3. Click OK.
By default, the Java language version used to compile your project is based on your
project's compileSdkVersion (http://google.github.io/android-gradle-dsl/current
/com.android.build.gradle.BaseExtension.html#com.android.build.gradle.BaseExtension:compileSdkVersion)

(because different versions of Android support different versions of Java). If


necessary, you can override this default Java version by adding the following
CompileOptions {} (http://google.github.io/android-gradle-dsl/current
/com.android.build.gradle.internal.CompileOptions.html)

block to your build.gradle le:

android {
compileOptions {
sourceCompatibility JJaavvaaVVeerrssiioonn.VERSION_1_6
targetCompatibility JJaavvaaVVeerrssiioonn.VERSION_1_6
}
}

For more information about where compileSdkVersion is dened, read about the
module-level build le (https://developer.android.com/studio/build/index.html#module-level).

Set proxy settings


Proxies serve as intermediary connection points between HTTP clients and web
servers that add security and privacy to internet connections.

To support running Android Studio behind a rewall, set the proxy settings for the
Android Studio IDE. Use the Android Studio IDE HTTP Proxy settings page to set the
HTTP proxy settings for Android Studio.
When running the Android Plugin for Gradle from the command line or on machines
where Android Studio is not installed, such as continuous integration servers, set
the proxy settings in the Gradle build le.
Note: After the initial installation of the Android Studio bundle, Android Studio
can run with internet access or off-line. However, Android Studio requires an
internet connection for Setup Wizard synchronization, 3rd-party library access,
access to remote repositories, Gradle initialization and synchronization, and
Android Studio version updates.

Set up the Android Studio proxy


Android Studio supports HTTP proxy settings so you can run Android Studio behind
a rewall or secure network. To set the HTTP proxy settings in Android Studio:
1. From the main menu choose File > Settings > Appearance & Behavior > System
Settings > HTTP Proxy.
2. In Android Studio, open the IDE Settings dialog.
On Windows and Linux, choose File > Settings > IDE Setting > HTTP Proxy.
On Mac, choose Android Studio > Preferences > IDE Setting > HTTP Proxy.
The HTTP Proxy page appears.
3. Select auto-detection to use an auto-conguration URL to congure the proxy
settings or manual to enter each of the settings. For a detailed explanation of
these settings, see HTTP Proxy (https://www.jetbrains.com/idea/help/http-proxy.html).
4. Click Apply to enable the proxy settings.

Android Plugin for Gradle HTTP proxy settings


When running the Android Plugin from the command line or on machines where
Android Studio is not installed, set the Android Plugin for Gradle proxy settings in
the Gradle build le.
For application-specic HTTP proxy settings, set the proxy settings in the
build.gradle le as required for each application module.
apply plugin: 'com.android.application'

android {
...

defaultConfig {
...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
}
...

For project-wide HTTP proxy settings, set the proxy settings in the
gradle/gradle.properties le.

# Project-wide Gradle settings.


...
systemProp.http.proxyHost=proxy.company.com
systemProp.http.proxyPort=443
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.auth.ntlm.domain=domain
systemProp.https.proxyHost=proxy.company.com
systemProp.https.proxyPort=443
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.auth.ntlm.domain=domain
...

For information about using Gradle properties for proxy settings, see the Gradle
User Guide (http://www.gradle.org/docs/current/userguide/build_environment.html).
Note: When using Android Studio, the settings in the Android Studio IDE HTTP
proxy settings page override the HTTP proxy settings in the gradle.properties
le.

You might also like