My 4GB RAM, Intel Core i5 system came down down to its knees with high disk and RAM usage by Android Studio(I can see it in the task manager, nothing else is using the RAM and disk). The gradle build takes about 10-15 mins for a simple project.
Is there any solution?
According to Android Studio's official system requirements, it takes at minimum 3 GB RAM to run smoothly. Honestly, its a lot and I believe that is the biggest cause of being it too slow all the time. The android developers are always complaining about the speed of Android Studio and how its slow ALL THE TIME.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. in the project gradle. properties.
gradle, if you have minifyEnabled for debug, remove it. I had it in my project and it took ~2-3 minutes to build.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With