Although Android Studio has now been updated to the Android Studio 2.1 version, build version android-studio-bundle-143.2739321. However, installing this version is installed according to your own standards, so you need to make a series of adjustments after installation. The following article is based on 3 aspects of the explanation. For Android studio itself, Gradle, do not adjust the occurrence of the compilation problem.
Android Studio Optimization
Compilation optimization requires two steps, described below.
Step One: Gradle compilation optimization
Modify it in the root directory of the project. Modify Gradle.properties,
Gradle.properties the location of the file (h/gradle.properties)
Project-wide Gradle settings.
IDE (e.g. Android Studio) users:
Gradle settings configured through the IDE  would override
Any settings specified in this file.
For more details about 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 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
When configured, Gradle'll run in incubating parallel mode.
The option should only being used with decoupled proj ECTs. More details, visit
Http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec: decoupled_projects
Org.gradle.parallel=true
Based on the description of the file, my settings are:
Org.gradle.jvmargs=-xmx3062m-xx:maxpermsize=512m-xx:+heapdumponoutofmemoryerror-dfile.encoding=utf-8
Org.gradle.parallel=true
Org.gradle.daemon=true
noun explanation
Here are some references:
Http://www.cnblogs.com/mingforyou/archive/2012/03/03/2378143.html
-Org.gradle.jvmargs:JVM memory management, exists on the heap. Can be understood here as Gradle's memory management
--XMS: The initial allocated memory is specified by-XMS, heap memory.
--XMX: The maximum allocated memory is specified by-xmx, heap memory.
--XX:PERMSIZ:JVM use-xx:permsize to set non-heap memory initial values
--xx:maxpermsize Setting the maximum non-heap memory size
-Org.gradle.daemon=true
-Org.gradle.parallel=true
Step two: Android Studio optimizer
Locate the Android Studio installation directory.
My installation directory is in F:\Android\AndroidStudio\Soft\bin
In this file gradle.properties
-server
-xms512m
-xmx2048m
-xx:maxpermsize=350m
-xx:reservedcodecachesize=240m
-xx:+useconcmarksweepgc
-xx:softreflrupolicymspermb=50
-da
-djna.nosys=true
-djna.boot.library.path=
-djna.debug_load=true
-djna.debug_load.jna=true
-dsun.io.usecanoncaches=false
-djava.net.preferipv4stack=true
-xx:+heapdumponoutofmemoryerror
-didea.paths.selector=androidstudio2.1
-didea.platform.prefix=androidstudio
From this file, you can make an understanding change based on the above noun interpretation. The above is my own settings.
Pre-optimization-existing problems transformclasseswithdexfordebug
- Error:execution failed for task ': App:transformclasseswithdexfordebug '.
Com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException: Java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException: Org.gradle.process.internal.ExecException:Process ' command ' C:\Program files\java\jdk1.8.0_77\bin\java.exe " Finished with Non-zero exit value 3
- error:unexpected top-level ERROR:
- Error:java.lang.OutOfMemoryError:GC Overhead limit exceeded
- For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To does this set org.gradle.jvmargs=-xmx2048m in the project Gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Reason
When compiling with Gradle, the compilation memory is insufficient.
Workaround
Modify it in the root directory of the project. Modify Gradle.properties,
Set org.gradle.jvmargs=-xmx2048m.
The problem is resolved after the modification.
Android Sutido Compile speed optimization