I'm using a mac with 16gb memory, ssd hdd and still Gradle sync takes 15mins+ every time I build, clean or open the project, are there any Android Studio optimisations possible to reduce this time.
-----update----
All of these helped to some extent
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx5120M -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError . //increase Xmx and -XX:MaxPermSize accordingly
example:
buildscript {
repositories {
google() //1st priority in search
repo2()
repo3()
repo4()
mavenCentral()
jcenter() //least priority, when not found in all above repos
}
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. Now build time is normal.
One bit of a downside is that it takes roughly 3 minutes to re-sync when we "Import Gradle Project".
You're probably using a +
symbol on the libraries you added to your project (and have a very slow internet connection). For example: compile 'com.android.support:support-v4:+'
This will make on every sync() gradle will check online if there's a new version. If you change to specific version number, for example: compile 'com.android.support:support-v4:22.2.0'
Then gradle will use the cached version that already been downloaded to your development machine.
I would try to change the gradle version of your project to 2.4. If I recall correctly, studio uses 2.2 by default. I tried and I got slightly better build times on a small project. Maybe you can get better improvements.
Here you can find how: Using gradle 2.4 in Android Studio
Just go to
File->Settings->Gradle
and tick the Offine work check box
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