Any solution for Android Studio slow gradle build and high disk usage?

混江龙づ霸主 提交于 2019-11-29 22:20:29

You need to upgrade your PC though but there are few things you can do to make it faster

1. Increase the memory size of Android Studio:

Open the file located at /bin/studio.vmoptions and Change the content from

-Xms128m
-Xmx800m

to

-Xms256m
-Xmx1024m

Xms specifies the initial memory allocation pool. Your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

Save the studio.vmoptions file and restart Android Studio.

2. Improve Gradle performance:

Create a file named gradle.properties in

/home/<username>/.gradle/ (Linux)
/Users/<username>/.gradle/ (Mac)
C:\Users\<username>\.gradle (Windows)

and add the line:

org.gradle.daemon=true

This helps a lot, with org.gradle.daemon set to true Gradle reuses computations from previous builds and cache information about project structure, files, tasks etc. in memory so it won’t have to start up the entire Gradle application every time.

Source

Lluis Felisart

For me Android Studio slowness has a strong relationship with Task Manager showing a 100% disk usage most of time. I have done three things on my Windows 10:

1 - Disable "Windows Search" service

2 - Disable "Superfetch" service

3 - If you have Google Chrome, go to Settings> Show Advanced Settings ...> Privacy> "Prefetch resources to load pages more quickly" and untick it.

Disk usage is now far lower and Android Studio builds far faster. Hope it will help!

PD: To disable a service pres WindowsKey + R then enter services.msc, find the service > right click > Properties > Init > Disable.

You can avoid this gradle build process, on times gradle build is not necessary.

  1. Use: Run > Edit Configurations.
  2. In this new window, click the green plus icon > Android App.
  3. on the right frame, go to "Before launch", mark "gradle-aware Make", and click the red minus icon. Give this configuration a name, and press "OK" button.
  4. From now on, every time you run your app, you can choose your new configuration, and no gradle build process will be generated.

This may not apply your changes in code on runtime, so you highly recommended to leave the original configuration too for times you need the gradle build.

My 4GB RAM

Get more RAM. Android Studio takes a bit. JVM takes a bit. OS needs some. 4GB is not going to work really.

build takes about 10-15 mins

because it swaps as hell. Get more RAM.

Get expendable RAM upto 8Gb

My laptop has intel i3 processor with 8Gb expendable RAM and I have alloted 4 Gb of RAM to Android Studio only. It runs fast. And one more important thing you may use Genymotion instead of inbuilt Android Studio AVD that is much faster and less system images will be created in your system which will reduce the usage of your hard disk.

roshan posakya

For Ubuntu

sudo dpkg --add-architecture i386

sudo apt-get update

sudo apt-get install libncurses5:i386 libstdc++6:i386 zlib1g:i386

i found here Android Studio fails to build new project, timed out while wating for slave aapt process

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!