It was with the same problem, so I decided to help, to increase the speed of Build Gradle, modify your settings and scripts as follows:
1 - Click File > Settings > Gradle > and Modify as below:
- Select the Offline work option and click OK
2 - Click File > Settings > Compiler > and Modify as below:
- Select the above four options "Compile, Make, Sync, Configure" and put in
Command-line Options: --offline
and click OK
3 - modify the following script build.Gradle(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 a warning appears upstairs, click on Try Again...
or Sync Now
, and see the result.
Tip: In case your Android Studio is taking too long to start, recommend also see this post on how to increase IDE memory.
I hope I helped. I worked, the Gradle is faster.
Thank you for your reply. I will try to do so.
– Leonan Leonardo