Android Studio 缓慢的 gradle 构建和高磁盘使用率的任何解决方案? [英] Any solution for Android Studio slow gradle build and high disk usage?

查看:27
本文介绍了Android Studio 缓慢的 gradle 构建和高磁盘使用率的任何解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 4GB RAM,Intel Core i5 系统由于 Android Studio 的磁盘和 RAM 使用率高而瘫痪(我可以在任务管理器中看到它,没有其他东西在使用 RAM 和磁盘).对于一个简单的项目,gradle 构建大约需要 10-15 分钟.

My 4GB RAM, Intel Core i5 system came down down to its knees with high disk and RAM usage by Android Studio(I can see it in the task manager, nothing else is using the RAM and disk). The gradle build takes about 10-15 mins for a simple project.

有什么解决办法吗?

推荐答案

虽然您需要升级您的 PC,但您可以采取一些措施使其更快

You need to upgrade your PC though but there are few things you can do to make it faster

1.增加 Android Studio 的内存大小:

打开位于/bin/studio.vmoptions 的文件并更改内容

Open the file located at /bin/studio.vmoptions and Change the content from

-Xms128m
-Xmx800m

-Xms256m
-Xmx1024m

Xms 指定初始内存分配池.您的 JVM 将使用 Xms 内存量启动,并且最多可以使用 Xmx 内存量.

Xms specifies the initial memory allocation pool. Your JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory.

保存 studio.vmoptions 文件并重启 Android Studio.

Save the studio.vmoptions file and restart Android Studio.

2.提高 Gradle 性能:

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

并添加以下行:

org.gradle.daemon=true

这有很大帮助,将 org.gradle.daemon 设置为 true Gradle 重用以前构建的计算并缓存有关项目结构、文件、任务等的信息.内存,因此不必每次都启动整个 Gradle 应用程序.

This helps a lot, with org.gradle.daemon set to true Gradle reuses computations from previous builds and cache information about project structure, files, tasks etc. in memory so it won’t have to start up the entire Gradle application every time.

来源

这篇关于Android Studio 缓慢的 gradle 构建和高磁盘使用率的任何解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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