我最近从Eclipse升级到Android Studio,但我并不喜欢这种体验。我比较的是Windows 7 64位终极版,16GB内存,英特尔i7 4770运行NVidia Geforce 780,如果重要的话,我运行的是最新的JDK和最新的Android Studio。

Android Studio在构建项目时非常缓慢,我可以接受,但它也非常消耗资源,有时会使PC速度变慢。

每当我在AS中构建或运行任何东西时,我的PC似乎变得极其缓慢。如果我点击“Gradle build running”旋转器,它也会导致屏幕闪烁,偶尔会让我的第二个显示器空白,我觉得这很奇怪。内存的使用也飙升到3GB,我发现什么都不做就过度了(这是在几次构建后空闲的时候)。

此外,AS底部的面板一直在跳来跳去,这是一种糟糕的用户体验(从Android移动到消息到版本控制或其他任何临时的基础上,这取决于正在发生的事情,这是非常非常恼人的)。

我想知道的基本上是:

1)如何让Android Studio运行得更好?我可能做错了什么,或者错过了一些我不知道的更新,我相信其他人也注意到了这些行为,并找到了一些解决方案。

2)我如何“钉”底部面板,使他们不跳,而是让我,用户,导航到他们当我希望而不是自动切换他们?

非常感谢,如果这不是这些问题的正确位置,我再次道歉。

编辑1 更多评论:

我使用的是今天最新的稳定版本。这个版本是Android Studio 1.2.2 build # AI-141.1980579,于2015年6月3日发布 这种行为发生在使用Java 7或Java 8时。它似乎与Java版本无关。 我没有使用演示模式。只是普通的观点。 对构建配置进行更改(感谢@Blackbelt和他的回答)似乎对构建有所帮助,但迟缓和一般用户体验等其他问题仍然存在。


当前回答

有很多方法可以加速Android Studio。

加快gradle构建时间。 1.进入gradle项目。属性文件并从这两行中删除注释。 2.复制它。属性文件到您的。gradle文件夹,这样您就不需要为每个项目设置。 启用离线工作,这样Android studio/Gradle就不需要每次都在互联网上检查更新的文件。

其他回答

让android工作室快速运行的技巧:

启用脱机工作:

单击“文件->设置”。搜索“gradle”,在离线工作框中单击。 进入编译器(在Gradle下面的相同设置对话框中),并在命令行选项文本框中添加——offline。

提高Gradle性能

Gradle也可以优化。简单的方法是修改全局gradle中的设置。Windows - C:\users\your_name\.gradle\;Linux - /home/<用户名> / .gradle /;Mac- /Users/<username>/.gradle/;)在该文件中,添加这两行:

org.gradle.daemon=true
org.gradle.parallel=true

更多信息:http://www.viralandroid.com/2015/08/how-to-make-android-studio-fast.html

我发现了另一个原因——Thumbs.db,它严重影响了性能。

转到文件>设置>编辑器>文件类型并在字段中忽略文件和文件夹添加这个:Thumbs.db;

现在,Android Studio运行起来很有魅力。

在情况设置-Xmx4096m -XX:MaxHeapSize=256m(等。在上面提到的答案)做的工作,然后手动做这个:

步骤1:启动Android studio并关闭任何打开的项目(文件>关闭项目)。

步骤2:进入“Welcome”界面,进入“Configure > Settings”。

步骤3:选择构建、执行、部署>编译器

步骤4:将“Build process heap size (Mbytes)”修改为1024,“Additional Build process to VM Options”修改为-Xmx512m。

第五步:关闭或重启Android Studio。

提高android studio运行时性能的最佳方法是使用SSD Drive。这将极大地提高性能。我做了以上所有的事情,觉得我应该去买一台新的笔记本电脑,但突然我知道了SSD驱动器,我尝试了一下。Its Much Much better.....

建议:

必须说:如果你有任何机会,花一些钱买更好的PC(cpu), 这是最重要的…

调整:

Some people say, that OS (Operating System) might cause much slowness. For example, XP or LINUX (or etc) was mentioned to perform 70% faster (don't know why..). Disable VCS by File > Settings > Plugins and disable the following things : CVS Integration; Git Integration; GitHub; Google Cloud ... things; Subversion Integration; hg4idea; Editor is a resource eating too (especially on Large Monitors) and slow. Make it much much faster: click Help > Edit custom VM options and add these lines : -Dsun.java2d.d3d=false -Dsun.java2d.opengl=true save it and Restart Android Studio. If Android Studio has a proxy server setting and can't reach the server then it takes a long time to build and waiting for a timeout. Removing it helps much. File > Settings > Appearance & Behavior > System settings > HTTP Proxy. Another Useful quote (from article): Modules are expensive… On my current project I had to build some libraries from scratch and had to fork some that almost fitted my needs but not quite! If that modules are not constantly modified, it’s important to have this into consideration: the time needed to compile them from scratch, or even to check if the previous individual module build is up-to-date, can be up to almost 4x greater than to simply load that dependency as a binary .jar/.aar. Hint: run the gradle build -profile for an HTML report showing where the time goes regarding the build process. Note: keep that “unnecessary” modules in your version control system for the eventuallity of a quickfix/improvement in that dependency. In your Gradle build script, use only specific Google Service, like: compile 'com.google.android.gms:play-services-maps:...' Instead of full Google Library: compile 'com.google.android.gms:play-services:...' (Compile time goes from 2 minutes to around 25 seconds). Gradle configures every project before executing tasks, regardless of whether the project is actually needed for the particular build. In global gradle.properties adding this will help much: org.gradle.configureondemand=true Surprisingly, some people say , they solved problem by reducing: 1) heapsizes to -Xmx256m (instead of higher values); 2) Emulator Ram-size (from Edit AVD > Advanced Settings);

每天的建议:

不要同时运行多个项目。 使用一次后不要关闭模拟器(每次都使用相同的模拟器运行应用程序;如果你测试大型应用,最好使用真正的手机而不是模拟器)。 每次在模拟器中运行你的应用程序后都清理你的项目-点击构建>清洁项目(或重建),你可以使用键盘快捷键。