Modify the following files and settings
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.
android {
dexOptions {
incremental true
javaMaxHeapSize "8g"
}
}
#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 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"
-
-
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)