本文介绍了Android Gradle构建缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图弄清楚为什么我们的Gradle构建如此之慢.当前,每次您击中构建而没有任何更改时,构建时间约为45秒.这是一个单模块项目.我已经启用了性能分析,大部分时间都花在:app:dexDebug上.我们使用Gradle 2.8进行构建,我的dex选项如下:

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 =否 增量真实 javaMaxHeapSize"4g" }

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

从个人资料报告中::app 43.957s(总计):app:dexDebug 28.727s

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

有没有办法加快速度?为什么每次都必须重建dex?

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

推荐答案

这可能会引起一些启发:

This might shed some light:

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

Gradle在transformClassesWithDexForDebug上构建缓慢

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

尝试禁用数据绑定:

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

也尝试

 ./gradlew  assembleDebug --profile

这篇关于Android Gradle构建缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:05