I had the same problem, so I decided to help, to increase Gradle Build speed, modify your settings and scripts as follows:
1 - Click File > Settings > Gradle > and Modify as below:
- SelecttheOfflineworkoptionandclickOK
2-ClickFile>Settings>Compiler>andModifyasbelow:
- Selectthefouroptionsabove"Compile, Make, Sync, Configure" and put in
Command-line Options: --offline
and click OK
3 - Modify the following script build.grad (Module: app) - add dexOptions :
apply plugin: 'com.android.application'
android {
...
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
Add this snippet:
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
}
4 - Modify the following script gradle.properties (Project Properties) :
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on 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 is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
Add this snippet:
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.parallel=true
If you see a warning above, click on Try Again...
or Sync Now
, and see the result.
Tip: If your Android Studio is taking too long to start, I also recommend seeing this #
I hope I have helped. with me it worked, Gradle is faster.