我最近从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和他的回答)似乎对构建有所帮助,但迟缓和一般用户体验等其他问题仍然存在。


当前回答

这里让我感到痛苦的不是编译,而是输入。我可以禁用所有智能功能,回到notepad++,就像TomTsagk在评论中建议的那样。今天我需要更多的核心和内存。

作为魔鬼的拥护者,我认为打字不应该需要16Gb的八进制PC。喜欢Sajan Rana的建议,但这里的事情太缓慢了,感觉像是安慰剂。

为了公平起见,我使用的是1.4RC1,它离稳定分支还差得远。关闭互联网有一点帮助。同时使用XML布局的设计(预览)和文本视图的新特性非常有用。

不,这太荒谬了。永远不要离开稳定的航道。

其他回答

除了遵循现有答案中提到的优化(没有多大帮助,仍然非常缓慢),下面的做法对我来说很管用。

我有6 GM内存和i5处理器的惠普笔记本电脑,android工作室仍然非常慢。 在检查任务管理器的内存使用情况后,注意到有一个名为“HP Touchpoint Analytics Client”的软件占用了超过1gb的内存。 在谷歌搜索后发现这是惠普在Windows 10上安装的间谍软件。

卸载了一堆惠普软件,这些软件什么都不做,还会降低系统速度。 现在,Android studio的速度相当快——Gradle的构建在30秒内就完成了,而之前需要2分钟多。每次击键都需要5秒钟来响应,现在它是实时的,性能与Eclipse相当。

这对于其他厂商的笔记本电脑来说可能也是如此,比如戴尔等。 惠普的间谍软件真的把Windows 10用户的用户体验搞砸了。 卸载它们,这将有助于Android工作室,并改善整体笔记本电脑的体验。

希望这能帮助到一些人。谢谢。

建议:

必须说:如果你有任何机会,花一些钱买更好的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);

每天的建议:

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

不要编辑工作室。vmoptions,可能不起作用。

在它。属性文件(在应用程序目录)添加这个:

org.gradle.parallel=true
org.gradle.jvmargs=-Xmx7g -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

这个答案涉及到在你已经把Xmx和Xms内存设置弄清楚之后,Windows 10的Gradle构建速度变慢的问题。

视窗防护

就Windows Defender而言,仅仅通过“文件”或“文件夹”将文件夹/文件添加到Windows Defender排除列表是不够的。

你必须添加属于Android Studio / Gradle / Java(嵌入式JDK或Oracle JDK)的目录作为“进程”排除到Windows Defender:

看一下大卫·罗森的答案 在Gradle构建过程中…监视Windows任务管理器的进程 在Windows Defender中,为包含文件/可执行文件的目录添加“进程”排除,你看到在与Android Studio / Gradle相关的构建过程中使用CPU

这显然会带来安全隐患。

以下描述了有关在Windows Defender中使用“进程”排除(而不是添加简单的“文件”或“文件夹”排除)的更多细节:

A file name with full path causes the particular binary file to be excluded, i.e. any files it touches, regardless of where the file is located, will not be scanned by Windows Defender. A file name without any path causes any binary file with this file name to be excluded regardless of its location. A path followed by a "*" (e.g. c:\my\private\tools*) causes any binaries under this path to be excluded. Any files touched by these processes will be excluded. This is different from a path exclusion, where files touched by any process under the excluded path is excluded.

这里的关键字是....将这些排除作为“进程”类型的排除考虑到“二进制接触的文件”,而不是手动查找并排除由Android Studio / Gradle生成的每个文件/文件夹。

Windows文件索引

Windows文件索引似乎也会降低Gradle构建的速度。关闭Gradle / Android Studio使用的目录的Windows文件索引。

以下是我排除的“Windows文件索引”和“Windows防御程序”:

 C:\Program Files\Android\*
 C:\Users\<yourUserAcct>\.android\*
 C:\Users\<yourUserAcct>\.AndroidStudio3.0\*
 C:\Users\<yourUserAcct>\.gradle\*
 C:<pathToYourAndroidStudioProjectFolder>

我注意到AS从HDD传输了太多的数据。这是非常烦人的,尤其是在开始写一行新代码的时候。所以,我认为更好的办法是用SSD重新安装硬盘。我的i5有6gb内存,即使在构建时,CPU的负载也很少超过50%。所以,最薄弱的地方是HDD。