So I have been working on a simple app in Android Studio and since last couple of days, whenever I click "Run", it takes more than 5 minutes to build. It didn't used to be this slow. I don't know why. It says "Gradle Build Running" and then app is loaded after 5 minutes. And this happens on both the emulator and on my android device. My grade version is 2.10 I looked up this issue and I have tried everything that other similar posts have suggested including:
org.gradle.daemon=true
in gradle.properites fileBelow are the screen shots.
Even after doing all these, my grade build takes 5+ minutes. This is what was there in the event log:
10:27:57 AM Executing tasks: [:app:clean, :app:generateDebugSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:generateDebugAndroidTestSources, :app:assembleDebug]
10:34:24 AM Gradle build finished in 6m 26s 378ms
Any suggestions will be helpful. Thanks in advance :)
Check your Internet connection. If internet speed is very slow gradle build will also take long time to build. I check by change my wifi internet connection with another one good speed connection.
android:android-maps-utils:0.4+' . Dynamic Dependencies slow down your build since they keep searching for the latest builds every time. To improve the performance we need to fix the version in place. Use only those dependencies that you need.
Enable "Dex In Process" for faster app builds (for Android Studio 2.1).
increase the amount of memory allocated to the Gradle Daemon VM by 1 Gb, to a minimum of 2 Gb, using the org.gradle.jvmargs property:
org.gradle.jvmargs=-Xmx2048m
Read about it here: Faster Android Studio Builds with Dex In Process
Other solutions here have not helped me yet. I am seeing builds lasting 30+ minutes only to end with Error:Out of memory: GC overhead limit exceeded
. But I have made slight progress the past few days.
Note: I do not believe this is a solution to the problem, just a workaround until Jack works out the kinks
I added the following to my build gradle:
android {
....
defaultConfig {
....
jackOptions {
enabled true
additionalParameters('jack.incremental': 'true')
}
}
compileOptions {
incremental true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize '4096m'
}
}
For some reason, adding
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
to my gradle.properties made no difference. I had to add it in the dexOptions
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With