Original: 60961723
Practice the most effective way to improve the Android studio run, compile speed scheme
The most effective way to improve the Android studio compilation speed: Improve the Computer Configuration! --Lu Xun
It is true that Lu Xun said that it is the most effective way to improve the configuration, but it is sometimes difficult for me to wait for the cock, so let's look at the following optimizations.
First, the installation of the problem 1, the installation is completed after the start of the card dead
Just opened studio on the Gradle building interface no longer moving (to connect to the wall of the network download), then we need to screen this internet download operation, find the studio installation directory, Locate the Idea.properties file, open it, add the following line to the configuration, the role of the initial opening to not let it connect to Google to update.
disable.android.first.run=true
2. Change the VM size of Studio
As limit the size of the Java Virtual machine startup memory, limit the maximum heap memory, when as run longer, memory is insufficient, will be frequently triggered gc,as will naturally get stuck, serious direct black screen, so, we put the corresponding required memory are configured larger, The 32-bit system opens the Studio.exe.vmoptions file, and if it is 64-bit open studio64.exe.vmoptions, change the following configuration to adjust appropriately according to the respective configuration.
-Xms512m-Xmx4096m-XX:MaxPermSize=2048m-XX:ReservedCodeCacheSize=1024m
Second, cancel some networking operations or use offline Mode 1, open the File->settings->appearance &behavior->system setting->updates, the two selection boxes are deselected.
2. Use offline work and local Gradle
The first time to launch the need to download Gradle, address: https://gradle.org/releases, download the corresponding version put to c:\user{username}.gradle\wrapper\dists\ Gradle-3.3-all (version modified according to the downloaded version)
Setting->build,execution,deployment->gradle, offline work selected, and select Use local gradle distribution, the path is as installation path gradle/gradle-x.xx.x
Third, the optimization of the compilation scheme 1, to open the Gradle daemon (pro-Test comparison of the configuration, can improve 50%, before the gradle.properties written Gradle.properties.txt, is also a number of Baidu articles to mislead ~! )
When Android studio encounters an error, it often causes Android studio to hang up, and in order to prevent the launch of the program, another thread is turned on to guard the Android studio process, specifically. Under C:\Users.gradle This directory, create the Gradle.properties configuration file and copy the following configuration for optimization.
# 编译时使用守护进程org.gradle.daemon=true #JVM最大允许分配的堆内存,按需分配 org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8#使用并行编译org.gradle.parallel=true org.gradle.configureondemand=true
2, try to use a third-party repository jar, AAR files to import their own projects, or download third-party libraries to local, and then as a local module to import their own projects, do not use Gradle in the Maven dependency (using offline mode will be error)
Take compile ' com.squareup.okhttp:okhttp:2.0.0 ' for example:
- Baidu Search: Maven Warehouse
- Open maven Warehouse URL: http://mvnrepository.com/
- Enter keyword: okhttp
- Find the corresponding Lib
- Open and find the corresponding version 2.0.0
- Click on the version number in the red box above to open
- There are some arr in Central, this is a jar in the first red box, click Download
- Added in Build.gradle: Compile files (' Libs/okhttp-2.0.0.jar ')
Appendix:
- http://blog.csdn.net/fuchaosz/article/details/51146091
"Turn" practice is the most effective way to improve the Android studio run, compile speed scheme