简体   繁体   English

为什么Gradle需要这么长时间才能建造?

[英]Why is Gradle taking so long to build?

My Gradle build is taking between 1 minute and 2 minutes and I'm uncertain what's going on. 我的Gradle构建过程需要1到2分钟,我不确定发生了什么。 On Event Log I see a single entry most of the time 在事件日志中,大多数时候我只看到一个条目

Executing tasks: [:app:generateDebugSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar, :app:assembleDebug] 执行任务:[:app:generateDebugSources,:app:prepareDebugUnitTestDependencies,:app:mockableAndroidJar,:app:assembleDebug]

I have no idea what this task is doing, I've checked work offline setting hoping this to make a difference but I had no luck. 我不知道这个任务在做什么,我检查了work offline设置,希望能有所作为,但是我没有运气。

Pass the --profile option to Gradle to profile build execution time and generate a report in the <buildDir/reports/profile directory. --profile选项传递给Gradle来概要分析构建执行时间,并在<buildDir/reports/profile目录中生成报告。 For more information see the docs about Profiling a build . 有关更多信息,请参阅有关对构建进行概要分析的文档。

Gradle build time depends on a lot of factors and may get slower as the codebase of your project grows, you add more third-party dependencies. Gradle的构建时间取决于很多因素,并且随着项目代码库的增长而变慢,您添加了更多的第三方依赖项。

For instance if you use Google Play Services dependencies, you can break those apart and only use the specific dependency you need. 例如,如果您使用Google Play服务依赖项,则可以将它们分开,仅使用所需的特定依赖项。

For example try to use 例如尝试使用

compile 'com.google.android.gms:play-services-maps:8.4.0' 编译'com.google.android.gms:play-services-maps:8.4.0'

instead of 代替

compile 'com.google.android.gms:play-services:8.4.0' 编译'com.google.android.gms:play-services:8.4.0'

This is just an example which is misused by a lot of people but as I said it's usually based on how large your codebase is. 这只是一个被很多人误用的示例,但是正如我所说,这通常是基于您的代码库有多大。 And obviously the hardware configurations, your machine have.. 很明显,您的计算机具有硬件配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM