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

Configure Android Studio - Android Developers

The document provides instructions for customizing Android Studio settings through configuration files. It describes how to customize the Virtual Machine options file (studio.vmoptions) to adjust settings like the maximum heap size. It also describes customizing the IDE properties file (idea.properties) to modify settings such as the plugins folder path. The document recommends increasing the maximum heap size if working on large projects or systems with sufficient RAM. It also describes how to export and import IDE settings between projects.

Uploaded by

Maaz Adrees
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

Configure Android Studio - Android Developers

The document provides instructions for customizing Android Studio settings through configuration files. It describes how to customize the Virtual Machine options file (studio.vmoptions) to adjust settings like the maximum heap size. It also describes customizing the IDE properties file (idea.properties) to modify settings such as the plugins folder path. The document recommends increasing the maximum heap size if working on large projects or systems with sufficient RAM. It also describes how to export and import IDE settings between projects.

Uploaded by

Maaz Adrees
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

19/04/2020 Configure Android Studio | Android Developers

Configure Android Studio


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

Android Studio provides access to two con guration les through the Help menu:

studio.vmoptions (#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 speci c documentation about emulator and device setup and use, see the following topics:

Managing virtual devices (/tools/devices)

Using hardware devices (/tools/device)

OEM USB drivers (/tools/extras/oem-usb)

Find your configuration files

Both con guration les are stored in the con guration folder for Android Studio. The name of
the folder depends on your Studio version. For example, Android Studio 3.3 has the folder
name AndroidStudio3.3. The location of this folder depends on your operating system:

Windows: %USERPROFILE%\.CONFIGURATION_FOLDER

macOS: ~/Library/Preferences/CONFIGURATION_FOLDER

Linux: ~/.CONFIGURATION_FOLDER

https://developer.android.com/studio/intro/studio-config#offline 1/16
19/04/2020 Configure Android Studio | Android Developers

You can also use the following environment variables to point to speci c 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

https://developer.android.com/studio/intro/studio-config#offline 2/16
19/04/2020 Configure Android Studio | Android Developers

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 for Android Studio processes, such as the core IDE, Gradle daemon, and
Kotlin daemon.

Android Studio automatically checks for possible heap size optimizations and noti es you if it
detects that performance can be improved.

Figure 1. A noti cation about recommended memory settings.

If you use a 64-bit system that has at least 5 GB of RAM, you can also adjust the heap sizes for
your project manually. To do so, follow these steps:

1. Click File > Settings from the menu bar (or Android Studio > Preferences on macOS).

2. Click Appearance & Behavior > System Settings > Memory Settings.

3. Adjust the heap sizes to match your desired amounts.

https://developer.android.com/studio/intro/studio-config#offline 3/16
19/04/2020 Configure Android Studio | Android Developers

4. Click Apply.

If you changed the heap size for the IDE, you must restart Android Studio before the new
memory settings are applied.

Note: Allocating too much memory can degrade performance.

Export and import IDE settings

You can export a Settings.jar le that contains all or a subset of your preferred IDE settings
for a project. You can then import the JAR le into your other projects and/or make the JAR le
available to your colleagues to import into their projects.

For more information, see Exporting and Importing Settings


 (https://www.jetbrains.com/help/idea/2019.1/exporting-and-importing-settings.html) at IntelliJ IDEA.

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/2019.1/ le-idea-properties.html).

https://developer.android.com/studio/intro/studio-config#offline 4/16
19/04/2020 Configure Android Studio | Android Developers

#---------------------------------------------------------------------
# Uncomment this option if you want to customize path to user installed plugins
# 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 system memor
# if code assistance is enabled. Remove this property or set to very large numbe
# code assistance for any files available regardless their size.
#---------------------------------------------------------------------
idea.max.intellisense.filesize=2500
#---------------------------------------------------------------------
# This option controls console cyclic buffer: keeps the console output size not
# specified buffer size (Kb). Older lines are deleted. In order to disable cycle
# idea.cycle.buffer.size=disabled
#---------------------------------------------------------------------
idea.cycle.buffer.size=1024
#---------------------------------------------------------------------
# Configure if a special launcher should be used when running processes from wit
# Using Launcher enables "soft exit" and "thread dump" features
#---------------------------------------------------------------------
idea.no.launcher=false
#---------------------------------------------------------------------
# To avoid too long classpath
#---------------------------------------------------------------------
idea.dynamic.classpath=false
#---------------------------------------------------------------------
# There are two possible values of idea.popup.weight property: "heavy" and "medi
# If you have WM configured as "Focus follows mouse with Auto Raise" then you ha
# set this property to "medium". It prevents problems with popup menus on some
# 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 useful when
# Remote Desktop Connection for instance.
#---------------------------------------------------------------------
idea.use.default.antialiasing.in.editor=false
#---------------------------------------------------------------------
# Disabling this property may lead to visual glitches like blinking and fail to
# on certain display adapter cards.
#---------------------------------------------------------------------

https://developer.android.com/studio/intro/studio-config#offline 5/16
19/04/2020 Configure Android Studio | Android Developers

sun.java2d.noddraw=true
#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under Window
#---------------------------------------------------------------------
sun.java2d.d3d=false
#---------------------------------------------------------------------
# Workaround for slow scrolling in JDK6
#---------------------------------------------------------------------
swing.bufferPerWindow=false
#---------------------------------------------------------------------
# Removing this property may lead to editor performance degradation under X Wind
#---------------------------------------------------------------------
sun.java2d.pmoffscreen=false
#---------------------------------------------------------------------
# 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

Configure the IDE for low-memory machines

If you are running Android Studio on a machine with less than the recommended speci cations
(see System Requirements (/studio#Requirements)), you can customize the IDE to improve
performance on your machine, as follows:

Reduce the maximum heap size available to Android Studio: Reduce the maximum heap
size for Android Studio to 512Mb. For more information on changing maximum heap
size, see Maximum heap size (#adjusting_heap_size).

Update Gradle and the Android plugin for Gradle: Update to the latest versions of Gradle
and the Android plugin for Gradle to ensure you are taking advantage of the latest
improvements for performance. For more information about updating Gradle and the
Android plugin for Gradle, see the Android plugin for Gradle Release Notes
 (/studio/releases/gradle-plugin).

https://developer.android.com/studio/intro/studio-config#offline 6/16
19/04/2020 Configure Android Studio | Android Developers

Enable Power Save Mode: Enabling Power Save Mode turns off a number of memory-
and battery-intensive background operations, including error highlighting and on-the- y
inspections, autopopup code completion, and automatic incremental background
compilation. To turn on Power Save Mode, click File > Power Save Mode.

Disable unnecessary lint checks: To change which lint checks Android Studio runs on
your code, do the following:

1. Click File > Settings (on macOS, Android Studio > Preferences) to open the
Settings dialog.

2. In the left pane, expand the Editor section and click Inspections.

3. Click the checkboxes to select or deselect lint checks as appropriate for your
project.

4. Click Apply or OK to save your changes.

Debug on a physical device: Debugging on an emulator uses more memory than


debugging on a physical device, so you can improve overall performance for Android
Studio by debugging on a physical device (/studio/run/device).

Include only necessary Google Play services as dependencies: Including Google Play
Services as dependencies in your project increases the amount of memory necessary.
Only include necessary dependencies to improve memory usage and performance. For
more information, see Add Google Play Services to Your Project
 (https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project).

Turn on O ine Mode for Gradle: If you have limited bandwitch, turn on O ine Mode to
prevent Gradle from attempting to download missing dependencies during your build.
When O ine Mode is on, Gradle will issue a build failure if you are missing any
dependencies, instead of attempting to download them. To turn on O ine Mode, do the
following:

1. Click File > Settings (on macOS, Android Studio > Preferences) to open the
Settings dialog.

2. In the left pane, expand Build, Execution, Deployment and then click Gradle.

3. Under Global Gradle settings, check the O ine work checkbox.

4. Click Apply or OK for your changes to take effect.

https://developer.android.com/studio/intro/studio-config#offline 7/16
19/04/2020 Configure Android Studio | Android Developers

Reduce the maximum heap size available for Gradle: Gradle's default maximium heap
size is 1,536 MB. Reduce the value by overriding the org.gradle.jvmargs property in
the gradle.properties le, as shown below:

# Make sure to gradually decrease this value and note


# changes in performance. Allocating too lttle memory may
# also decrease performance.
org.gradle.jvmargs = -Xmx1536m

Do not enable parallel compilation: Android Studio can compile independent modules in
parallel, but if you have a low-memory system you should not turn on this feature. To
check this setting, do the following:

1. Click File > Settings (on macOS, Android Studio > Preferences) to open the
Settings dialog.

2. In the left pane, expand Build, Execution, Deployment and then click Compiler.

3. Ensure that the Compile independent modules in parallel option is unchecked.

4. If you have made a change, click Apply or OK for your change to take effect.

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, do
the following:

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:compile
SdkVersion)

https://developer.android.com/studio/intro/studio-config#offline 8/16
19/04/2020 Configure Android Studio | Android Developers

(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 JavaVersion.VERSION\_1\_6
        targetCompatibility JavaVersion.VERSION\_1\_6
    }
}

For more information about where compileSdkVersion is de ned, read about the module-level
build le (/studio/build#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

https://developer.android.com/studio/intro/studio-config#offline 9/16
19/04/2020 Configure Android Studio | Android Developers

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 menu bar, click File > Settings (on macOS, click Android Studio > Preferences).

2. In the left pane, click Appearance & Behavior > System Settings > HTTP Proxy. The
HTTP Proxy page appears.

3. Select Auto-detect proxy settings to use an automatic proxy con guration URL for the
proxy settings or Manual proxy con guration to enter each of the settings yourself. For a
detailed explanation of these settings, see HTTP Proxy
 (https://www.jetbrains.com/help/idea/2019.1/http-proxy.html).

4. Click Apply or OK for your changes to take effect.

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-speci c 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
    }
    ...
}

https://developer.android.com/studio/intro/studio-config#offline 10/16
19/04/2020 Configure Android Studio | Android Developers

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.

Optimize Android Studio performance on Windows

Android Studio performance on Windows can be impacted by a variety of factors. This section
describes how you can optimize Android Studio settings to get the best possible performance
on Windows.

Minimize the impact of antivirus software on build speed

Some antivirus software can interfere with the Android Studio build process, causing builds to
run dramatically slower. When you run a build in Android Studio, Gradle compiles your app’s

https://developer.android.com/studio/intro/studio-config#offline 11/16
19/04/2020 Configure Android Studio | Android Developers

resources and source code and then packages the compiled resources together in an APK.
During this process, many les are created on your computer. If your antivirus software has
real-time scanning enabled, the antivirus can force the build process to halt each time a le is
created while the antivirus scans that le.

To avoid this issue, you can exclude certain directories from real-time scanning in your
antivirus software.

Caution: To ensure that your computer is safe from malicious software, you should not completely disable
real-time scanning or your antivirus software.

The following list shows the default location of each Android Studio directory that you should
exclude from real-time scanning:

Gradle cache

%USERPROFILE%\.gradle

Android Studio projects

%USERPROFILE%\AndroidStudioProjects

Android SDK

%USERPROFILE%\AppData\Local\Android\SDK

Android Studio system les

%USERPROFILE%\.AndroidStudio<version>\system

Customize directory locations for Group Policy controlled environments

If a Group Policy limits which directories you can exclude from real-time scanning on your
computer, you can move your Android Studio directories to one of the locations that the
centralized Group Policy already excludes.

The following list shows how to customize the location of each Android Studio directory, where
C:\WorkFolder is the directory that your Group Policy already excludes:

Gradle cache

https://developer.android.com/studio/intro/studio-config#offline 12/16
19/04/2020 Configure Android Studio | Android Developers

De ne the GRADLE_USER_HOME environment variable to point to


C:\WorkFolder\.gradle.

Android Studio projects

Move or create project directories in an appropriate subdirectory of C:\WorkFolder. For


example, C:\WorkFolder\AndroidStudioProjects.

Android SDK

Follow these steps:

1. In Android Studio, open the Settings dialog (Preferences on macOS), then navigate
to Appearance & Behavior > System Settings > Android SDK.

2. Change the value of Android SDK Location to C:\WorkFolder\AndroidSDK.

To avoid downloading the SDK again, make sure to copy the existing SDK directory,
located at %USERPROFILE%\AppData\Local\Android\SDK by default, to the new
location.

Android Studio system les

Follow these steps:

1. In Android Studio, click Help > Edit Custom Properties.

Android Studio prompts you to create an idea.properties le if you don't already


have one.

2. Add the following line to your idea.properties le:

idea.system.path=c:/workfolder/studio/caches/trunk-system

Configure offline build dependencies

If you'd like to build your project without a network connection, follow the steps below to
con gure the IDE to use o ine versions of the Android Gradle Plugin and Google Maven
dependencies.

https://developer.android.com/studio/intro/studio-config#offline 13/16
19/04/2020 Configure Android Studio | Android Developers

If you haven't already done so, download the o ine components (/r/studio-o ine/downloads)
from the downloads page.

Download and unzip o ine components

After you have downloaded the o ine components, unzip their contents into the following
directory, which you might need to create if it doesn’t already exist:

On Windows: %USER_HOME%/.android/manual-offline-m2/

On macOS and Linux: ~/.android/manual-offline-m2/

To update the o ine components, proceed as follows:

1. Delete the content inside the manual-offline-m2/ directory.

2. Re-download the o ine components (/r/studio-o ine/downloads).

3. Unzip the contents of the ZIP les you downloaded into the manual-offline-m2/
directory.

Include o ine components in your Gradle project

To tell the Android build system to use the o ine components you've downloaded and
unzipped, you need to create a script, as described below. Keep in mind, you need to create and
save this script only once, even after updating your o ine components.

1. Create an empty text le with the following path and le name:

On Windows: %USER_HOME%/.gradle/init.d/offline.gradle

On macOS and Linux: ~/.gradle/init.d/offline.gradle

2. Open the text le and include the following script:

def reposDir = new File(System.properties['user.home'], ".android/manual-off


def repos = new ArrayList()
reposDir.eachDir {repos.add(it) }
repos.sort()

allprojects {
  buildscript {

https://developer.android.com/studio/intro/studio-config#offline 14/16
19/04/2020 Configure Android Studio | Android Developers

    repositories {
      for (repo in repos) {
        maven {
          name = "injected_offline_${repo.name}"
          url = repo.toURI().toURL()
        }
      }
    }
  }
  repositories {
    for (repo in repos) {
      maven {
        name = "injected_offline_${repo.name}"
        url = repo.toURI().toURL()
      }
    }
  }
}

3. Save the text le.

4. (Optional) If you’d like to verify that the o ine components are working as intended,
remove the online repositories from your project’s build.gradle les, as shown below.
After you've con rmed that your project builds correctly without these repositories, you
can put them back into your build.gradle les.

buildscript {
    repositories {
        // Hide these repositories to test your build against
        // the offline components. You can include them again after
        // you've confirmed that your project builds ‘offline’.
        // google()
        // jcenter()
    }
    ...
}
allprojects {
    repositories {
        // google()
        // jcenter()
    }

https://developer.android.com/studio/intro/studio-config#offline 15/16
19/04/2020 Configure Android Studio | Android Developers

    ...
}

Note: This script applies to all Gradle projects you open on the workstation.

Content and code samples on this page are subject to the licenses described in the Content License (/license). Java
is a registered trademark of Oracle and/or its a liates.

Last updated 2020-03-19.

https://developer.android.com/studio/intro/studio-config#offline 16/16

You might also like