Developing applications for Android often faces problems one annoying problem: Android Studio can work slowly, especially on average computer configurations. Long indexing, eternal project assembly via Gradle and interface freezes can kill the productivity of even an experienced engineer. However, there are many proven ways to make your development environment fly without buying new hardware.

In this article we will look in detail at how to optimize the IDE, configure the Java virtual machine settings and speed up the build of projects. You will learn about hidden settings that are disabled by default, but are critical for performance. Even on an old laptop You can achieve acceptable operating speed if you properly distribute system resources.

Before moving on to complex manipulations, it is worth understanding what exactly is consuming resources. Most often, the bottleneck becomes RAM or disk speed. If your project is stored on a regular HDD, switching to SSD will give the most noticeable speed increase. But if upgrading hardware is now impossible, software tuning will be your salvation.

Tuning memory and JVM parameters

The first step to speeding up work is to allocate enough RAM for the development environment itself. By default, Android Studio may use too modest limits, which leads to frequent garbage collections (Garbage Collection) and interface slowdowns. You need to edit the configuration file studio64.exe.vmoptions (for Windows) or studio.vmoptions (for macOS/Linux).

Find this file through the menu Help โ†’ Edit Custom VM Options. The key parameters here are -Xms (initial heap size) and -Xmx (maximum heap size). For comfortable work on modern projects, it is recommended to set the value -Xmx at least 2048m, and preferably 4096m, if you have free memory. It is also worth increasing the metaspace parameters to avoid errors when loading many plugins and libraries.

โš ๏ธ Attention: Do not set the value -Xmx more than 80% of the available RAM of your computer. The remaining memory is needed by the operating system and other processes, otherwise the system will begin to actively use the page file, which will lead to the opposite effect - severe brakes.

After changing the parameters, be sure to restart the IDE for the settings to take effect. You can check the current memory consumption by turning on the indicator in the bottom panel of the status bar: go to View โ†’ Appearance โ†’ Status Bar Widgets โ†’ Memory Indicator. This will allow you to monitor in real time how effectively the allocated resource is being used.

๐Ÿ’ก

If after changing the settings the IDE stops starting, delete or edit the .vmoptions file manually in the Android Studio configuration folder to reset the settings to default values.

Optimizing the Gradle build system

The most common reason long work - this is the assembly system Gradle. It is inherently resource intensive, but can be significantly speeded up with the right caching flags and settings. Open the file gradle.properties in the root of your project or in the global folder .gradle in the user's home directory.

To enable parallel building, add the line org.gradle.parallel=true. This will allow Gradle to run tasks for different project modules simultaneously, using all the cores of your processor. It is also extremely important to enable incremental builds and caching by adding org.gradle.caching=true. This will prevent recompilation of tasks that have already been executed and whose input data has not changed.

  • ๐Ÿš€ Increase the heap size for the Gradle daemon: add org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError.
  • โšก Disable offline update checking: use the flag --offline when building if internet is unstable.
  • ๐Ÿ’พ Set the cache path to a fast disk: make sure that the folder .gradle is located on the SSD and not on the slow HDD.

Another important parameter is org.gradle.daemon=true. The Gradle daemon is a background process that keeps the runtime in memory between builds. The first launch may be long, but all subsequent builds will occur instantly, since you will not need to restart the JVM.

๐Ÿ“Š Where is your Android Studio project stored?
On the system SSD
On a separate SSD
On a regular HDD
On an external drive

Disable unnecessary plugins and functions

Android Studio comes with a huge set of pre-installed plugins, many of which you may not need at all. Each active plugin consumes memory and participates in the project indexing process. Go to settings via File โ†’ Settings โ†’ Plugins (or Android Studio โ†’ Preferences on Mac) and carefully examine the list of installed ones.

Disable support for languages โ€‹โ€‹and frameworks that you do not use. For example, if you only write in Kotlin and Java, you probably don't need plugins for C/C++, Groovy, or server-specific support. It's also worth disabling version control integration if you're using a third-party client, although the built-in Git usually works quite easily.

Plugin / Feature Memory Impact Recommendation
Android NDK Support High Disable if you do not work with C++
Google Cloud Tools Medium Disable for local development
Subversion Integration Low Disable if you only use Git
Mercurial Integration Low Disable if you do not use Hg

In addition to plugins, you can disable heavy real-time code inspection functions. Go to Settings โ†’ Editor โ†’ Inspections and uncheck those checks that are not critical to you. This will reduce the load on the processor when typing. However, do this carefully so as not to miss important errors in the code.

Which plugins are the heaviest?

The most resource-intensive are usually plugins for database support (Database Tools), tools for working with Docker and Kubernetes, as well as plugins for frameworks that are not used in the project, for example, Spring or JSF in pure Android project.

Setting up the emulator and using physical devices

Starting the emulator Android Virtual Device (AVD) is one of the most difficult operations. The emulator creates a full-fledged virtual machine that competes for resources with Android Studio itself. If your computer does not have excess power, consider working on a physical device.

Connect your smartphone via USB and turn it on USB debugging. This will free up a significant portion of RAM and CPU time. Installing an application on a real device is often faster than launching a cold emulator. In addition, you will be able to test the application in real conditions, evaluating the performance of the camera, GPS and sensors without unnecessary complications.

โš ๏ธ Attention: The interfaces and settings of the emulator may change with Android Studio updates. Always check the latest system resource requirements for new versions of Android in the official Google documentation, as images of new OS versions are becoming more and more demanding.

If using an emulator is unavoidable, be sure to enable hardware acceleration. In the AVD Manager settings, make sure that the Graphics value is selected in the Hardware - GLES 2.0/3.0field. Also use system images labeled Google APIs or Play Storewhich are better optimized than standard AOSP images. For Intel processors, make sure that HAXMis installed, and for AMD or new Intel processors, virtualization is enabled in the BIOS and used Android Emulator Hypervisor Driver.

๐Ÿ’ก

Using a physical device instead of an emulator can reduce the code-build-test cycle time by 2-3 times on computers with less than 16 GB of RAM.

Clearing the cache and managing indexing

Over time, Android Studio accumulates a huge amount of temporary files and index data, which can become fragmented or corrupted. This leads to the fact that the IDE begins to become "stupid" even on powerful machines. Regularly clearing the cache is a simple but effective procedure.

To perform cleaning, go to menu File โ†’ Invalidate Caches / Restart. In the dialog that appears, select the option Invalidate and Restart. This will force the environment to rebuild all project indexes from scratch. The first time after the restart, indexing will take time, but then the work will proceed smoothly. It's also useful to periodically clean out the folder .idea in the project root if you encounter strange configuration errors, but make a backup copy of your settings first.

  • ๐Ÿ—‘๏ธ Delete the folder build in the project root before a major refactoring.
  • ๐Ÿ”„ Use the command ./gradlew clean to completely clear build artifacts before the final build.
  • ๐Ÿ“‚ Regularly delete old logs and temporary files from the IDE cache system folder.

Another tip: exclude folders from indexing that do not contain source code. If the project has large folders with media files, logs or generated data, add them to Settings โ†’ Directories as Excluded. This will prevent the IDE from trying to parse thousands of unnecessary files every time you change.

โ˜‘๏ธ Monthly IDE Maintenance

Done: 0 / 4

Hardware requirements and disk impact

No software settings can fully compensate for the lack of basic hardware. For modern development for Android, availability SSD drive is not just a recommendation, but a necessity. The speed of reading small files, of which there are thousands in an Android project, on the HDD is catastrophically low.

The minimum comfortable characteristics for development today are as follows: a processor with 4 physical cores (preferably 6-8), at least 16 GB of RAM and an SSD with a capacity of 256 GB or more. If you have 8 GB of memory, you will have to constantly balance between open browser tabs, the emulator and the studio itself, which will inevitably lead to swapping and slowdowns.

Pay attention to the cooling system. During long-term compilation, the processor is loaded at 100%. If the laptop overheats, throttling occurs and frequencies drop, which directly affects the build speed. Regularly clean dust vents and use cooling pads.

Why is an SSD so important for Gradle?

The Gradle build system actively reads and writes thousands of small class and resource files. The random access speed (IOPS) of SSDs is hundreds of times higher than that of mechanical hard drives, which reduces build time from minutes to seconds.

How to increase Kotlin compilation speed?

To speed up Kotlin compilation, add a build.gradle parameter kotlin.incremental=true and use the experimental flag kotlin.caching.enabled=true. Also make sure that you are using the latest stable version of the Kotlin plugin, as the compiler is constantly being optimized.

Why does Android Studio slow down when typing code?

Most often this is due to the work of code inspectors or indexing. Try temporarily disabling "Power Save Mode" in the File menu to check if it is accidentally enabled, or vice versa, enable it for diagnostic purposes. Also check if a heavy process is running in the background, for example, anti-virus scanning of the project folder.

Is it possible to disable checking for Android Studio updates?

Yes, this can be done in the settings Appearance & Behavior โ†’ System Settings โ†’ Updatesby unchecking the "Check for updates regularly". This will save some bandwidth and resources, but remember to manually check for updates every few months for security patches.

What to do if the emulator won't start?

Check if virtualization (VT-x or AMD-V) is enabled in your computer's BIOS. Also make sure that the correct emulator drivers are installed (HAXM or AEHD) and that the system image matches the architecture of your processor (x86 for PC, not ARM, unless there is special emulation).

How to reset all Android Studio settings to factory settings?

Hold down the keys when starting the IDE Ctrl+Shift+Alt (Windows/Linux) or Cmd+Shift+Option (macOS). A window will appear asking you to reset your settings. This will help if the configuration has been damaged and no other methods help speed up the work.