android studio构建项目一直卡在gradle build running界面

翻译 2016年05月31日 21:24:29




Create a file named in whatever directory applies:

/home/<username>/.gradle/ (linux)

/Users/<username>/.gradle/ (Mac)

C:\Users\<username>\.gradle (Windows)



IDE Settings

IDE settings



You can ignore gradle update-to-date checks.

enter image description here


Configuration File

Create a file named in whatever directory applies:

  • /home/<username>/.gradle/ (Linux)
  • /Users/<username>/.gradle/ (Mac)
  • C:\Users\<username>\.gradle (Windows)



Ensure you are using the latest development versions.

Command Line Arguments

The --daemon --parallel --offline command line arguments for Gradle builds work great. Learn about these options from the documentation.


An optimized Gradle properties file ( includes:

# Project-wide Gradle settings.

# IDE (e.g. Android Studio) users:
# Settings specified in this file will override any Gradle settings
# configured through the IDE.

# For more details on how to configure your build environment visit

# The Gradle daemon aims to improve the startup and execution time of Gradle.
# When set to true the Gradle daemon is to run the build.
# TODO: disable daemon on CI, since builds should be clean and reliable on servers

# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit

# Enables new incubating mode that makes Gradle selective when configuring projects. 
# Only relevant projects are configured which results in faster builds for large multi-projects.

Gradle properties works local if you place them at projectRoot\ and globally if you place them at user_home\.gradle\ Properties applied if you run gradle tasks from console or directly from idea:

IDE Settings

Or enable gradle properties from the IDE settings

IDE settings


Prefer @aar dependencies over library projects.

Search aar package on mavenCentral (, github (, or build it manually from sources and put into libs folder. If you are not editing sources of the dependency library you should not build it every time with your project sources.


Consider to exclude project and cache files from antivirus scanning. This is obviously a trade off with security (don't try this at home!). But if you switch between branches a lot, then antivirus will rescan files before allowing gradle process to use it, which slows build time (in particular AndroidStudio sync project with gradle files and indexing tasks). Measure build time and process CPU with and without antivirus enabled to see if it is related.


Don't use auto-import feature (yet) due to known bug which will slow down the IDE.

Fabric Crashlytics

Fabric has typo at the documentation pointing to the private maven repo which needs authorization.

More Reading

An article on Gradle describes a few settings to increase its speed.

Stop Gradle build processes的解决办法

刚刚编译工程的时候突然出现如下错误,各种clean各种rebuild都不行,但是其它的工程是能跑起来的。 解决的方法就是把.gradle文件夹下的含有tasks名称的文件夹删除就可以了,如图 ...
  • donglin1234
  • donglin1234
  • 2016年09月28日 14:41
  • 387

深入浅出Android Gradle构建系统(三:build task)

Gradle中常用的一些task的介绍,Gradle Java插件以及Gradle Android插件常用的一些task的介绍...
  • lzyzsd
  • lzyzsd
  • 2015年01月05日 23:07
  • 13885

gradle build running很久的问题

转自:原文地址:,转载请注明出处。  谢谢大神 一.开启gradle单独的守护...
  • twtje0304_01
  • twtje0304_01
  • 2017年01月17日 21:31
  • 3245

Android Studio Gradle Build Running 特别慢的问题

转自:原文地址:,转载请注明出处。  谢谢大神 一.开启gradle单独的守护进程 ...
  • u011889786
  • u011889786
  • 2015年12月28日 11:24
  • 21323

gradle 2.10 The Gradle Daemon使用详解

Chapter 6. The Gradle Daemon From Wikipedia… A daemon is a computer program that runs as a backg...
  • LANGZI7758521
  • LANGZI7758521
  • 2016年06月06日 14:22
  • 1938

android studio 一直卡在Gradle:Build Running的解决办法

在使用AS开发安卓应用程序的时候经常会遇到Gradle build running一直在运行甚至卡死的情况,本文列出了几种解决方法以供参考。...
  • a549742320
  • a549742320
  • 2016年09月13日 13:52
  • 37694


目录结构│ build.gradle └─src └─main └─java └─com └─manning ...
  • u012885276
  • u012885276
  • 2017年03月10日 17:16
  • 1218


目标: 使用SpringMVC编写的一个HelloWorld程序。 初学Gradle只能一步步摸索前进...
  • lgh1992314
  • lgh1992314
  • 2017年03月20日 21:31
  • 2272

AndroidStudio Unable to start the daemon process(无法启动Gradle守护进程)

Android Studio+Gradle安装完毕后无法正常创建工程,显示 Unable to start the daemon process.  This problem might be...
  • ching_zhi
  • ching_zhi
  • 2017年01月11日 15:50
  • 7825

android studio 创建项目一直停留在building gradle project info

Android Studio是基于JetBrains公司的IDEA开发的,android Studio里的项目都是由Gradle构建的,Gradle集合了Ant和Maven的优点,又解决了他们的缺点,...
  • a249130
  • a249130
  • 2017年06月28日 21:11
  • 1486
您举报文章:android studio构建项目一直卡在gradle build running界面