您的位置:首页 > 产品设计 > UI/UE

Android Stuido 好卡怎么办?不要急,兄弟来教你

2015-07-28 09:13 537 查看
最近使用Android studio 开发app,编译的时候特别卡,经常卡死。我的机器 i3 + 8G,按道理来说流畅的跑个androidstudio还是绰绰有余的...

于是在各大论坛寻找解决方案,在此记录下来,让同病相连的弟兄们可以早点解脱....

方法一:开启gradle单独的守护进程

在下面的目录下面创建 gradle.properties 文件:

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

并在文件中增加:
org.gradle. daemon= true

同时修改项目下的 gradle.properties 文件也可以优化:
<span style="font-size:14px;"># 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= 512 m -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</span>


同时上面的这些参数也可以配置到前面的用户目录下的gradle.properties文件里,那样就不是针对一个项目生效,而是针对所有项目生效。

上面的配置文件主要就是做, 增大gradle运行的java虚拟机的大小,让gradle在编译的时候使用独立进程,让gradle可以平行的运行。

方法二:增加Androidstudio的运行内存

操作如下图:

1,打开 Androidstudio的安装路径下的
bin 目录

2,找到 studio.exe.vmoptions 和 studio64.exe.vmoptions 文件



3,修改 以上2个文件中的值 (下图是我修改后)

这些值起码在原有的基础上乘以2,如果是内存壕的话,可以尽可能的大。



我的Androidstudio 经过上述配置后,可以跑得飞起来了,哈啊哈!!!

兄弟还在等什么!!飞起来吧!!骚年
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: