简体   繁体   English

Android Studio Gradle太长

[英]Android studio gradle too long

在此处输入图片说明

my android studio build too time ,i print the log is show app:compileDevDebugJavaWithJavac has take my 37s , i build the project it take 53s ,too long to wait ... 我的android studio编译时间太长,我打印的日志是show app:compileDevDebugJavaWithJavac用了我的37s,我用53s构建了项目,时间太长了...

These are Gradle build tasks. 这些是Gradle构建任务。 Gradle is the build automation system of Android Studio and it has set of tasks to perform in order to build apk. Gradle是Android Studio的构建自动化系统,它具有一组要执行的任务以构建apk。 Each time you run/build project it goes through these list of tasks one after another. 每次您运行/构建项目时,它都会依次浏览这些任务列表。 Build time depends on your project code and dependencies you used in your project. 构建时间取决于项目代码和项目中使用的依赖项。

Gradle Build Life Cycle Gradle构建生命周期

Gradle is a language for dependency based programming. Gradle是一种用于基于依赖项编程的语言。 In Gradle terms this means that you can define tasks and dependencies between tasks. 用Gradle术语,这意味着您可以定义任务以及任务之间的依赖关系。 Gradle guarantees that these tasks are executed in the order of their dependencies, and that each task is executed only once. Gradle保证这些任务按照其依赖关系的顺序执行,并且每个任务仅执行一次。 These tasks form a Directed Acyclic Graph. 这些任务形成有向无环图。 There are build tools that build up such a dependency graph as they execute their tasks. 有一些构建工具在执行任务时会建立这种依赖关系图。 Gradle builds the complete dependency graph before any task is executed. 在执行任何任务之前,Gradle会构建完整的依赖关系图。

It is the Gradle build life cycle. 这是Gradle构建生命周期。 It has three phases 它分为三个阶段

*) Initialization *)初始化

*) Configuration *)配置

*) Execution *)执行

Official Document ion On Build LifeCycle 关于构建生命周期的官方文件

You may try to add the following code to your gradle.properties file: 您可以尝试将以下代码添加到gradle.properties文件中:

org.gradle.jvmargs=-Xmx5124m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.daemon=true
org.gradle.configureondemand=true
org.gradle.parallel=true

This may help speed up your gradle build. 这可能有助于加快构建gradle。

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

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