Android Gradle Build Slow

老子叫甜甜 提交于 2020-02-03 10:07:09

问题


I am trying to figure out why our Gradle build is so slow. Currently each time you hit build with no changes the build time is around 45 seconds. This is a single module project. I have turned on profiling and most of the time is spent on :app:dexDebug. We are build using Gradle 2.8 and my dex options are as follows:

dexOptions { preDexLibraries = false incremental true javaMaxHeapSize "4g" }

From the profile report: :app 43.957s (total) :app:dexDebug 28.727s

Is there a way to speed this up? Why does dex have to be rebuilt each time?


回答1:


This might shed some light:

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

Gradle build slow on transformClassesWithDexForDebug

https://code.google.com/p/android/issues/detail?id=187443&q=attachments%3D0&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

Try disabling data binding:

//    dataBinding {
//        enabled = true
//    }

Also try

 ./gradlew  assembleDebug --profile


来源:https://stackoverflow.com/questions/33306700/android-gradle-build-slow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!