Skip to content

Instantly share code, notes, and snippets.

@alshell7
Last active October 17, 2018 07:06
Show Gist options
  • Save alshell7/1a519bad8b30af285b312447ef305b54 to your computer and use it in GitHub Desktop.
Save alshell7/1a519bad8b30af285b312447ef305b54 to your computer and use it in GitHub Desktop.
Boost your Android Studio performance and speed up Gradle build time ⚡⚡⚡

Modify the following files and settings

File : gradle.properties

  org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m 
  org.gradle.daemon=true
  org.gradle.parallel=true
  org.gradle.configureondemand=false #Since Gradle 4.2, this is to be disabled, else can use it.

File : build.gradle (Module: app)

  android {
    dexOptions {
        incremental true
        javaMaxHeapSize "8g"
    }
  }

Android Studio > Help > Edit Custom VM Options (studio64.exe.vmoptions file)

#This is for a system with 8GB Ram, customise these below four attributes your own way

-Xms1024m
-Xmx2048m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=512m

#These below all can be used as such

-XX:+UseCompressedOops
-XX:-HeapDumpOnOutOfMemoryError
-Dfile.encoding=UTF-8
-XX:+UseConcMarkSweepGC
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled 
-XX:SoftRefLRUPolicyMSPerMB=50
-da
-Djna.nosys=true
-Djna.boot.library.path=
-Djna.debug_load=true
-Djna.debug_load.jna=true
-Dsun.io.useCanonCaches=false

Under Settings of Android Studio

  1. Under Build, Execution, Deployement >>> Gradle

    • Check "Use Local Gradle Distribution" -Pointing to the downloaded Gradle location (Example : Download Gradle Release distributive from https://services.gradle.org/distributions/ and extract it to a folder) (OR)

    • Go to C:/Users/%USER_NAME%/.gradle/wrapper/dists/ (Replace the %USER_NAME% with the user name of your current login to PC)

    • Point to any already downloaded recent Gradle distribution under the folder

    • Build the project (This makes the Android studio download the caches for offline)

    • Check "Offline Work"

  2. Under Build, Execution, Deployement >>> Compiler

    • Check "Compile independent modules in parallel"
    • Type in "Command-line Options: " as "--offline"
    • Check "Make Project Automatically"
    • Check "Configure on demand" (If Gradle < 4.2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment