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

近期使用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 经过上述配置后。能够跑得飞起来了,哈啊哈!

兄弟还在等什么。!飞起来吧!

。骚年

原文地址:https://www.cnblogs.com/jzssuanfa/p/6927123.html