Android Advanced Road - Gradle Build Accelerates Compilation

Article structure:

  • Early attention
  • Optimization method

Preliminary Note:

Pre-configuration (with or without matching)

  • View execution memory and allocated memory
    write picture description here

  • Thumbnail (for easy viewing)
    write picture description here

  • If you can't view it, please set it according to the picture below
    write picture description here

Notice:

No matter how to optimize the compilation speed, we need to restart As to take effect

Optimization method

Method 1 : Memory allocation (the size of the internal allocation depends on your computer configuration, the general computer configuration can be set as follows)

step:

  • Modify the memory allocation of AndroidStudio

write picture description here

  • Modify the data in the studio64.exe.vmoptions file (friendly reminder: you can rename the file suffix to meet the needs of modification, remember to change it back after modification!)

Parameter introduction :

-Xms1024m //JVM启动的起始堆内存
-Xmx4096m //AndroidStudio能使用的最大heap内存
-XX:MaxPermSize=1024m //最大的Permanent generation大小。存放的事类本身(不是对象),以及方法,一些固定的字符串等等。
-XX:ReservedCodeCacheSize=512m //设置JIT java compiler在compile的时候的最大代码缓存
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=300

This is the modified parameter map:

Modified parameter code:

-Xms1024m
-Xmx2048m
-XX:ReservedCodeCacheSize=1024m
-XX:+UseConcMarkSweepGC
-XX:SoftRefLRUPolicyMSPerMB=50
-Dsun.io.useCanonCaches=false
-Djava.net.preferIPv4Stack=true
-Djna.nosys=true
-Djna.boot.library.path=

-da

Precautions:

If you modify it according to the above picture and the compilation speed does not improve after restarting As, then please follow the picture below to see if you do this!

  • User directory, view the corresponding version of As
    write picture description here

  • Check if there is this file, if so, modify it~
    write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324725429&siteId=291194637