Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android studio 1.2 gradle is very slow

it's been a while that I'm using Android Studio, and up until now I was using 1.0.1, gradle was a bit slow, around 1.5 minute for assembleDebug (my project is really big!) but today I updated my AS to 1.2 and now same process takes about 7 to 10 minutes, and sometimes even with no result!

is there any setting I have to change to make it faster ? honestly taking 10 minute for every debug run is a nightmare !

Also most of the time, my cpu usage is arround 10 percent! (it is actually idle!) cause before when gradle was working it was on 100% almost all the time

like image 555
Muhammad Naderi Avatar asked May 04 '15 07:05

Muhammad Naderi


People also ask

Why is gradle so slow?

As our Android Studio project size increases, the gradle build performance becomes critical. The gradle speed for even the simplest project is pretty slow. Though every project comes up with it's own complexity and uniqueness which causes it to have a different build speed.

Why is Android Studio running so slow?

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.

How speed up Gradle build in Android?

For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB. in the project gradle.

Is Android Studio heavy?

In the previous versions, the android studio was more heavy software Google is updating it and making it more scalable for developers. But it is even also heavy software which will suck your computer's ram.


2 Answers

had the same problem.

What I did was to change the global gradle settings to offline work which can be done by going to Preferences => Gradle. This did make a difference.

Another method I have seen people use, but which I have not used yet is to create a gradle.properties in the gradle folder like so:

Just create a file named gradle.properties in the following directory:

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

Add this line to the file:

org.gradle.daemon=true 

Please check out this link for more options as well as a detailed explanation on speeding up gradle.

Hope this helps!.

like image 158
Smashing Avatar answered Sep 19 '22 18:09

Smashing


I was testing my app with Google+ log in. So I added release signing to debug version. App compiling in ~ 26 seconds.

build.gradle Module: app file

signingConfigs {     debug {         storeFile file(project.property("MyApp.signing"))         storePassword project.property("MyApp.signing.password")         keyAlias project.property("MyApp.signing.alias")         keyPassword project.property("MyApp.signing.password")     } } 

When I remove that ~ 7.5 seconds.

Next I tested offline grade

File - Settings - Build, Execution... - Build Tools - Gradle - Offline work

enter image description here

Now my app compiling in ~ 4.5 seconds.

Of course I also added turn on - Compile independent modules in parallel (may require larger heap size) - Make project automatically (only works while not running / debugging)

File - Settings - Build, Execution... - Compiler

enter image description here

like image 23
Eliasz Kubala Avatar answered Sep 18 '22 18:09

Eliasz Kubala