Before getting info speed up gradle build, we should know that, what is gradle build.Before eclipse, we dont have any automation scripts to build java and XML code to android apk. So that we used commands to generate apk. To optimize this process, gradle build come into the picture. Gradle is automated script to build and generate apk using android studio.
Gradle sync is automation process to download dependencies which are declare in gradle file. A simple example as shown below −
Step 1 − Open gradle.properties and add the following code as shown below
# Project-wide Gradle settings. # IDE (e.g. Android Studio) users: # Gradle settings configured through the IDE *will override* # any settings specified in this file. # For more details on how to configure your build environment visit # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. org.gradle.daemon = true org.gradle.parallel = true org.gradle.configureondemand = true org.gradle.jvmargs=-Djava.awt.headless = true -Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true
The above code going to increase build JVM MaxPermSize(gives 2GB max memory to JVM complier) and execute in parallel.
Step 2 − Now use the following process to speed up gradle.
Now open File → Setting →Build,Excution,Deployment → Gradle and check offline work as shown below −
Because every gradle going to sync with internet resources. So when you click on offline work, it will sync with offline resources as well.
Step 3 − Now use the following process to speed up gradle.
Now open File → Setting →Build,Excution,Deployment → complier and check all check boxs as shown below −