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

查看:199
本文介绍了对于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性能:

在其中创建一个名为gradle.properties的文件

Create a file named gradle.properties in

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

并添加以下行:

org.gradle.daemon=true

这很有帮助,将org.gradle.daemon设置为true 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天全站免登陆