Decreasing android studio 2.1 build time

2019-04-30 03:41发布

I was using android studio 1.5 earlier and i just upgraded to 2.1.But after the update my builds are taking much more time(from 15 sec to 2 min now)

Things I have tried as mentioned here

Enabled offline work in Settings

org.gradle.daemon=true
org.gradle.parallel=true

in gradle.properties file @ C:\Users\.gradle (Windows)

But still no difference. How can I reduce the build time?

3条回答
够拽才男人
2楼-- · 2019-04-30 04:20

have you tried instant run?

Steps to enable instant run:

  1. Open the Settings or Preferences dialog.

  2. Navigate to Build, Execution, Deployment > Instant Run and click Update Project

ref: http://tools.android.com/tech-docs/instant-run

some more tips : link

-Enable Configuration on Demand.
-Use Gradle Daemon.
-Newer versions of Gradle and Java are faster.
-Avoid doing expensive things during the configuration phase.
-Don’t use dynamic dependencies (`x.y.+`).
-Parallelize the build.
查看更多
forever°为你锁心
3楼-- · 2019-04-30 04:22

I also face the same issue with Android Studio

Please uncomment the line

org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

and increase the org.gradle.jvmargs=-Xmx1024m to org.gradle.jvmargs=-Xmx2048m

in gradle properties file

also include

defaultConfig {
    multiDexEnabled true
}

in your module level build file.

it worked for me, hope it worked for you too..!

查看更多
男人必须洒脱
4楼-- · 2019-04-30 04:44

From official source:

Windows defender real time protection is causing instant run slow downs. Add your project folder to windows defender's list of exclusion.

The video (Instant Run - Deep dive) on the official documentation page for Instant Run has a mention of this at around 7:40 (timestamp). It is strange that they have not put this down as text.

查看更多
登录 后发表回答