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

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

来源这里

http://stackoverflow.com/questions/16775197/building-and-running-app-via-gradle-and-android-studio-is-slower-than-via-eclips


1.

(创建一个文件名叫gradle.properties,放在对应一下的目录

Create a file named gradle.properties in whatever directory applies:

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

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

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

org.gradle.daemon=true

2.

IDE Settings

IDE settings

3.

你可以忽略Gradle更新(勾选)

You can ignore gradle update-to-date checks.

enter image description here

原文如下:

Configuration File

Create a file named gradle.properties in whatever directory applies:

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

Append:

org.gradle.daemon=true

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.

Overview

An optimized Gradle properties file (gradle.properties) 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
# http://www.gradle.org/docs/current/userguide/build_environment.html

# 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
org.gradle.daemon=true

# 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
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
org.gradle.parallel=true

# 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.
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:configuration_on_demand
org.gradle.configureondemand=true

Gradle properties works local if you place them at projectRoot\gradle.properties and globally if you place them at user_home\.gradle\gradle.properties. 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

Dependencies

Prefer @aar dependencies over library projects.

Search aar package on mavenCentral (http://gradleplease.appspot.com/), github (https://github.com/Goddchen/mvn-repo), 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.

Antivirus

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.

Warning

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.http://stackoverflow.com/a/27130652/624706

More Reading

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


解决接入mPaas一直Starting Gradle Daemon...问题 如若使用的是新版开发工具则在settings.gradle中加入一定要把 google()等注释掉如下。 阅读详情

相关推荐

Android Studio下载及安装和Gradle的配置

android studio 下载及安装和gradle的配置

adminstate的博客 6万+

解决Android Studio构建项目Gradle Build Runing

在 C:\Users\用户名.gradle 这个目录下创建文件 init.gradle 并填入以下内容 allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public' def ALIYUN_JCENTER...

Ghlerrix的博客 2130

理解与配置Android studio中的gradle

使用gradle构建android应用时,你总是需要这样一个文件:build.gradle。你应该已经看过这个文件了,如果没有看过的话,你现在就可以看一下,它没有多少内容。它的简洁性得益于它提供了很多对设置和属性的默认值。gradle是基于groovy语言的,但就使用它构建普通的工程的话,是可以不去学groovy的,如果想深入的做一下自定义的构建插件,可以考虑学一下groovy,因为它是基于jav

阳光玻璃杯 4万+

Starting a Gradle Daemon, 5 busy and 1 incompatible and 1 stopped Daemons could not be reused, use -...

执行gradle build出的问题,查看hs_err_pid11064.log日志文件发现,是电脑的RAM不足导致 转载于:https://www.cnblogs.com/lzj123/p/8352661.html

weixin_30325971的博客 2849

解决AS编译RN项目时一直Gradle:Resolve dependencies ':react-native-*******'的问题

在编译RN项目时,由于项目依赖的rn项目太多,导致在编译时一直在编译依赖上;把网络断开时会特别快,因为此时不会去更新新的依赖,一旦连上网,就会变得异常慢;解决办法:进入到指定的rn项目中,在主目录的build.gradle文件下,修改依赖的rn库为指定的版本号,具体与主项目rn版本号保持一直就行;...

washen_zhang的博客 4177

React Native项目gradle手动编译

最近在折腾,远程开发React Native 项目,我想实现在ssh命令行中。在服务器上自动编译RN 项目android),这样就可以使用高速的服务器来编译项目。 正解 cd android到工程目录后,执行以下命令即可完成debug 的apk生成。 gradlew assembleDebug 以下要探索过程,仅供参考。 查任务列表 cd /project/android执行以下命令,获取可执行的任务列表 gradlew tasks 查询结果如下(部分): android ./gradlew

lxyoucan的博客 2019

IDEA 安装Android插件时 android studio构建项目一直gradle build running界面

安装这个插件时一直gradle build running   打开设置Ctel+Ait+S  找到 Gradle   在这里如果你是没勾选上的,把这个勾选上然后应用,重新安装配置      ...

So_hhh的博客 1406

Android studio 一直Gradle:Build Running

问题:Android studio经常需要build调试app,但是有时会出现Gradle:Build Running中 解决方案: 1:在C:\Users\用户名.gradle新建一个文件gradle.properties,文件中添加内容 org.gradle.daemon=true 2:若添加后还是这样,转入build.gradle中,可以看到mavenCentral()拖慢,这就需要镜...

Aile 1万+

解决Android studio一直Gradle:Build Model

Android studio 一直Gradle:Build Running_爱乐写代码的博客-CSDN博客。2、转入build.gradle中,可以看到mavenCentral()拖慢,这就需要镜像了。1、在C:\Users\用户名.gradle新建一个文件gradle.

优秀技术文章收录 1万+

Android Studio build.gradle配置详解

Android Studio是采用gradle构建项目的,gradle是基于groovy语言的,如果只是用它构建普通Android项目的话,是可以不去学groovy的。当我们创建一个Android项目时会包含两个Android build.gradle配置详解文件,如下图: build.gradle位置.png 一、Project的build.gradle文件: 对应的build.gradle代码如下: // Top-level build file where you can add

h_bpdwn的博客 2万+

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

在使用AS开发安卓应用程序的时候经常会遇到Gradle build running一直在运行甚至死的情况,解决方法如下: 方法1: 1、在C:\User\<用户名>\.gradle 目录下新建一个gradle.properties文件,并在里面添加一行:org.gradle.daemon=true 2、打开AS,在Settings中设置Gradle的工作模式为offline,如下图: 这样就可以解决一直在running的问题了 方法2: 找到路径C:\Us...

jehuyang的博客 9574

Android Studio 中的 gradle 介绍及build.gradle配置文件详解

不同于 Eclispse,Android Studio 是采用 Gradle构建项目的,Gradle 是一个非常先进强大的项目构建工具,它使用了一种基于 Groovy 领域的特定语言(DSL)来声明项目设置,摒弃了基于 XML(如 Ant 和 Maven)的各种繁琐的配置,今天我们就来一起探讨 Android Studio 中强大的项目构建工具 Gradle ###一.gradle 是什么?...

muranfei的博客 3万+

Android studio2024的第一个安卓项目

解决方法:首先查看连接的设备查看是否使用了自定义布局查看安装的包使用构建 Android 应用调试版本的命令我是用构建时发现了问题:Java compiler version 23 has deprecated support for compiling with source/target version 8.(即java版本为23,不适用于目标版本8)璀﹀憡: [options] 婧愬€?8 宸茶繃鏃讹紝灏嗗湪鏈潵鍙戣鐗堜腑鍒犻櫎璀﹀憡: [options] 鐩爣鍊?

m0_69115733的博客 1798

关于Android StudioGradle各项配置

配置插件仓库和插件获取策略。配置项目的依赖解析方式,确保依赖从官方仓库获取,避免本地仓库问题。设置了项目名称。表示项目包含一个名为app的子模块,适用于多模块项目。在国内可能会遇到的问题,就是网络问题,导致我们没法正常下载到所需的插件和以来,因而我们通常会添加镜像源google() // Google仓库,主要用于 Android 相关的插件mavenCentral() // Maven 中央仓库gradlePluginPortal() // Gradle 官方插件仓库。

qq1342753906的博客 1万+

配置 build --- Android Gradle 插件 ---了解Android构建系统

Android 构建系统会编译应用资源和源代码,然后将它们打包成 APK 或 Android App Bundle 文件,供您测试、部署、签名和分发。 Android Studio 使用高级构建工具包 Gradle 来自动执行和管理构建流程,同时也允许您自行指定灵活的 build 配置。每项 build 配置均可定义各自的一组代码和资源,同时重复利用所有应用版本共用的部分。Android Gradle 插件与该构建工具包搭配使用,提供专用于构建和测试 Android 应用的流程和可配置设置。

半夏微凉科技 1463

android studio 常遇错误,界面Gradle详细讲解

前段时间经历了eclipse转换到android studio 的艰难历程经过了几个月的学习并使用现在在这里写下一篇教程-工具篇http://jingyan.baidu.com/article/ad310e80a9328a1849f49e30.html具体的安装教程 这里就不说了这个是百度经验的教程下面说一下 安装 studio 遇到的常见问题 问题一:‘tools.jar’ seems to b

v7428477的专栏 4881

安卓开发之Android Studio Gradle build running问题

问题 前阵子,朋友问我在Android studio上打开Gayhub项目时一直gradle build 这个界面上,好久都没跑完,特别慢,怎么解决?这一般是Gradle版本差异所导致的问题,由于国内墙的原因,当你没有这个Gradle版本时,下载是非常慢的。 朋友的思路 朋友说他的解决办法是打开gradle\wrapper\gradle-wrapper.properties文件,改为...

木子饼干的博客 1878

Android Studio创建一个安卓项目

目前不管事项目还是产品,都是有各种的APP、小程序,这里就跟大家分享一个App项目的搭建吧。 前提条件:需要安装JDK,这里要注意,AS要求JDK7及更高版本,这里就不必多说。 在新建项目之前,可以看一下已经下载的SDK,如果是经常开发,我们可以把常用的sdk都下载好 点击图标打开sdk管理器 勾选右下角,可以查看具体下载的api版本 点击切换查看sdktools 新建项目时,根据自定义向导finish以后,开始构建项目,可能会构建失败,一般情况是因为墙的问题,我们配置一..

天秤-white的博客 5007
皮卡丘爱吃鱼
博客等级 码龄18年 0粉丝 0原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值