Androidstudio optimizes gradle compilation efficiency and androidstudiogradle
Androidstuido uses gradle for Automatic Build and compilation. Sometimes it takes too long to compile a small amount of modifications. Recently, Boosting the performance for Gradle in your Android projects compiled by Erik Hellman (see article 1) the Optimization Method for this problem is mentioned.
1. Upgrade gradle to 2.4.
2.4 has been optimized in terms of compilation performance to improve compilation efficiency.
Add a task in the build. gradle file of your project (not the build. gradle file in the app). The Code is as follows:
task wrapper(type: Wrapper) {
gradleVersion = '2.4'
}
Note:
Open terminal and enter./gradlew wrapper. Then, gradle automatically downloads version 2.4, or manually downloads the gradle mv to the gradle path on the gradle official website.
The default ubuntu path is ~ /. Gradle/wrapper/dists/
2. Add daemon and compile in parallel
Add in gradle. properties of the project
Org. gradle. daemon = true
Org. gradle. parallel = true
3. Search for Gradle in File-> Settings and make the following changes (specify the location of the gradle to be manually downloaded). Otherwise, gradle will be downloaded from the Internet each time it is loaded, which means we can see that gradle is stuck.
Modify the red section above to select offine work for the grale-2.4 you downloaded
Experience, and find that the compilation performance is slightly improved.
Reference