极长的构建与摇篮(Android的工作室) [英] Extremely long build with Gradle (Android Studio)

查看:149
本文介绍了极长的构建与摇篮(Android的工作室)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我们正处在建设有乘以2分30秒,非常简单的变化的情况。这(与ANT)是惊人的慢,正在扼杀整个团队的工作效率。
我使用的Andr​​oid Studio和使用使用本地分销的gradle。
我试图给更多的内存来gradle这个:


  

org.gradle.jvmargs = -Xmx6096m -XX:MaxPermSize参数=2048米-XX:+ HeapDumpOnOutOfMemoryError -Dfile.encoding = UTF-8


很多更多的内存。并且它仍然给误差MEMORY不时。


  

在异常线程池1线程1java.lang.OutOfMemoryError:GC开销超过限制


惊人。我使用的是并行选项,守护程序:


  

org.gradle.parallel = TRUE


  
  

org.gradle.daemon = TRUE


这并不能真正帮助。

我已经把上述参数在〜/ .gradle / gradle.properties(我甚至怀疑Android的工作室忽视了,所以我测试 - 它不是忽略它)。

仍终端,我得到1:30的构建时间与Android Studio中2:30,所以不知道什么是错在那里。 1:30是依然疯狂相比,蚂蚁。如果你知道什么是Android的工作室正在做(或忽略,或者重写配置的gradle),我会感激知道了。

因此​​,只要CMD + B(简单编译)更改后超级快,像7秒。
但是,当涉及到运行的应用程序,它启动任务dexXxxDebug,这是刚刚杀死我们。
我试图把


  dexOptions {
    preDexLibraries = FALSE
}


于事无补。

据我所知,gradle这个可能还没有准备好用于生产环境,但我开始后悔我们决定这么早将其移动。
我们有很多的模块,这可能是问题的一部分,但是,这不是用Ant的问题。

任何帮助AP preciated,

有关执行时间的一些详细信息:

说明时间

 共建造时间1m36.57s
启动0.544s
设置和BuildSrc 0.026s
加载项目0.027s
配置项目0.889s
任务执行1m36.70s

时间吃:
:应用:dexDebug 1m16.46s


解决方案

我不明白为什么Android的工作室是不是在命令行速度较慢,但​​可以加快你的构建通过打开增量德兴。在你的模块的构建文件,将此选项添加到您的机器人块:

  dexOptions {
    真正的增量
}

dexOptions 阻止你也可以指定DEX过程堆大小,例如:

  dexOptions {
    真正的增量
    javaMaxHeapSize4G
}

这些选项从ADT-dev邮件列表上的一个线程(<一所href=\"https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ\">https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ)其中有一个多一点背景。

right now we are in a situation of having build times 2 minutes 30 seconds for very simple change. This (compared to ANT) is amazingly slow and is killing the productivity of the whole team. I am using Android Studio and using the "Use local gradle distribution". I've tried to give more memory to gradle:

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

A lot more memory. AND IT IS STILL GIVING ERRORS FOR MEMORY from time to time.

Exception in thread "pool-1-thread-1" java.lang.OutOfMemoryError: GC overhead limit exceeded

Amazing. I am using the parallel option and daemon:

org.gradle.parallel=true

org.gradle.daemon=true

It doesn't really help.

I've put the aforementioned parameters in ~/.gradle/gradle.properties (and I even doubted that Android studio is ignoring that, so I tested - it is not ignoring it).

Still from terminal I get 1:30 build time vs 2:30 in Android Studio, so not sure what is wrong there. 1:30 is STILL CRAZY compared to Ant. If you know what Android Studio is doing (or ignoring, or rewriting as gradle config), I'd be grateful to know.

So just CMD + B (simple compile) is super fast after changes, like 7 seconds. But when it comes to running the app, it starts the task dexXxxDebug, which is just killing us. I've tried putting

dexOptions {
    preDexLibraries = false
}

Doesn't help.

I understand that gradle is probably still not ready for production environments, but I'm starting to regret our decision to move so early to it. We have lots of modules, which is probably part of the problem, but that was not an issue with Ant.

Any help appreciated, Dan

Some more information about execution times:

Description Duration

Total Build Time    1m36.57s
Startup 0.544s
Settings and BuildSrc   0.026s
Loading Projects    0.027s
Configuring Projects    0.889s
Task Execution  1m36.70s

The time eater: :app:dexDebug 1m16.46s

解决方案

I'm not quite sure why Android Studio is slower than the command line, but you can speed up your builds by turning on incremental dexing. In your module's build file, add this option to your android block:

dexOptions {
    incremental true
}

In that dexOptions block you can also specify the heap size for the dex process, for example:

dexOptions {
    incremental true
    javaMaxHeapSize "4g"
}

These options are taken from a thread on the adt-dev mailing list (https://groups.google.com/forum/#!topic/adt-dev/r4p-sBLl7DQ) which has a little more context.

这篇关于极长的构建与摇篮(Android的工作室)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆