0

I use Android Studio to create application and I'm new to creating them. When a new project is started or even if I load a previously saved project, the time Gradle takes is too long, like even for 10 minutes sometimes. Not only while refreshing but for other events as well.

Is it related with the RAM I have (3 GB)? What should I do or customize to make it work faster, is it possible?

MMG
  • 3,226
  • 5
  • 16
  • 43
Mudit
  • 45
  • 1
  • 1
  • 8
  • How much RAM do you have in your System? check this [Similar Question](http://stackoverflow.com/questions/27176353/android-studio-takes-too-much-memory) – Rajwant Kaur Boughan Mar 25 '17 at 10:07

2 Answers2

1

I read this blogs and it explain all possible things which will help you to make build process faster.

First:

Gradle scripts directory(i.e., ~/.gradle/gradle.properties)

`# When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit org.gradle.parallel=true

When set to true the Gradle daemon is used to run the build. For local developer builds this is our favorite property.

The developer environment is optimized for speed and feedback so we nearly always run Gradle jobs with the daemon.

org.gradle.daemon=true`

Second :

Incease dex and heapsize

dexOptions { incremental true javaMaxHeapSize "3g" }

Third:

Also try to set gradle parameters in the settings file by increasing the max heap size in case you have a large project:

`# Specifies the JVM arguments used for the daemon process.

The setting is particularly useful for tweaking memory settings.

Default value: -Xmx10248m -XX:MaxPermSize=256m

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

For more details you can refer this link.

Justcurious
  • 2,201
  • 1
  • 21
  • 36
  • 1
    `javaMaxHeapSize "12g"` on a machine with 3GB of RAM? Really? – SergGr Mar 25 '17 at 10:37
  • Should it be less than 3g? – Mudit Mar 25 '17 at 10:40
  • You can set it heap size as per need here it can be javaMaxHeapSize "3g". Thanks @SergGr for pointing it out. – Justcurious Mar 25 '17 at 10:44
  • @Mudit, I would say that even "3g" it too much because most probably swapping is worse than Garbage Collection and you computer needs some memory to run other things as well (at least the OS itself, not to mention Android Studio). As a guess I'd set limit at 2 GB level but it is better for you to test on your real equipment and optimize basing on that. – SergGr Mar 25 '17 at 10:52
0

To speed up the Gradle Configure Settings.

File->Settings->Gradle->Check Offline Work

pradeep
  • 307
  • 1
  • 8
  • 1
    https://zeroturnaround.com/rebellabs/making-gradle-builds-faster/ import thirdparty library to speed up the gradle – pradeep Mar 25 '17 at 10:24