Why My Gradle Building Taking Too Much Time?
Solution 1:
you can set file->setting->search 'Gradle'-> check 'use local gradle distribution' and check 'offline work'.. in android studio. it will improve gradel building time.
Note: In newer version of Android studio, View->Tool Windows->Gradle->Toggle button of online/offline
Solution 2:
I too had this issue, what i had done was disabling instant run in the project settings, and rebuilding the project.
Solution 3:
If you are developing on Windows, then you should open Control Panel
-> Windows Defender
, then go to Settings
-> Excluded Files and Locations
-> Browse
, and add your project library (including the build
folder), and C:\Users\YourUser\.gradle
Also, add following to gradle.properties
in your project:
org.gradle.jvmargs = -Xms2048m -Xmx4096m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=1024m
Solution 4:
There are some tips for reducing your build time:
In your /.gradle/gradle.properties
file :
# When set to true the Gradle daemon is to run the build.org.gradle.daemon=true# Specifies the JVM arguments used for the daemon process.# The setting is particularly useful for tweaking memory settings.# Default value: -Xmx10248m -XX:MaxPermSize=256morg.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8org.gradle.parallel=trueorg.gradle.configureondemand=true
And you can disable the lint task when you build your project,add the task in your build.gradle file:
tasks.whenTaskAdded { task ->
if (task.name.equals("lint")) {
task.enabled = false
}
}
It is really useful for me! Hope it can help you!
Before reducing the building time, you should find out which step cost too much time.
./gradlew assembleDebug --dry-run--profile
It will product a report about the work of building in build/reports/profile/
direction, just read the report then to optimize your build work.
Post a Comment for "Why My Gradle Building Taking Too Much Time?"