Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio very slow gradle build

Tags:

android

I'm new to Android Studio..whenever I run my project it takes around 14 mins for gradle build..I've check for solutions to improve build speed as mentioned in here

My gradle.properties file:

## Project-wide Gradle settings.

org.gradle.daemon=true

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

org.gradle.parallel=true
org.gradle.configureondemand=true

but the problem is still the same and each of these lines are dim in color just like they were comment lines code. when the mouse is hovered on top there a message which says "Unused Property. This inspection reports all properties not referenced from outside of the properties file"

how can I fix this? Thanks

like image 697
Lum Avatar asked Oct 17 '15 08:10

Lum


People also ask

Why is Gradle build so slow?

One is your RAM, as Gradle Build is a processor bound operation its speed depends on RAM specifications of the machine. Other reason and the most common one is that you have not updated your tools. Update your tools, dependencies, Gradle version. With the new gradle version, my gradle build takes less than a minute.

Why is Android Studio running so slow?

There may be many plugins in Android Studio that you are not using it. Disabling it will free up some space and reduce complex processes. To do so, Open Preferences >> Plugins and Disable the plugins you are not using.


2 Answers

make gradle.propertiesfile in C:\Users\<username>\.gradle (Windows)

then,Add this line to the file:

org.gradle.daemon=true
like image 108
Akhil Jayakumar Avatar answered Oct 20 '22 01:10

Akhil Jayakumar


Solution for Linux/OSX may looks like this:

echo 'org.gradle.daemon=true' >> ~/.gradle/gradle.properties

echo 'org.gradle.configureondemand=true' >> ~/.gradle/gradle.properties

echo 'org.gradle.parallel=true' >> ~/.gradle/gradle.properties

echo 'org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8' >> ~/.gradle/gradle.properties

Using these commands you make changes in global gradle.properties file.

More info (together with detailed explanation) can he found here.

like image 23
duviteck Avatar answered Oct 20 '22 01:10

duviteck