在mac上加速android studio

英文部分没用。英文部分转载自:http://stackoverflow.com/questions/28784387/how-to-speed-up-android-studio-on-a-mac


I am trying to develop some native Android apps using Android Studio (latest) on OS X Yosemite. Currently Android Studio is simply unusable: it is too slow. I am not referring to the Android emulator, which was doubling the development time, but to the source code editor itself.

The main problem is that very often but not always (I would say almost always) it is not able to keep the pace of my editing: when I edit text, characters appear on the screen between one and two seconds later. If I delete characters, I never know which one I reached without waiting for a couple of seconds. If I right-click I wait for the equivalent of geological ages before something is displayed. It is almost impossible to use the graphical layout editor because it is sloooow.

I have also other problems, related to incredible bugs. But I want to focus on this basic functionality.

After a bit of research I ended up increasing its heap space. So I went into:

/Applications/Android Studio.app/Contents/bin

and modified these values:

-Xms512m
-Xmx6000m
-XX:MaxPermSize=1000m
-XX:ReservedCodeCacheSize=500m
-XX:+UseCompressedOops

Actually I have only increased the allocated memory for the first two of them.

Is there anyone developing for Android on a Mac who was able to increase this basic performance of Android Studio? Is there any hidden trick, combination of JVM and options able to make this app usable?

I am working on a MBP 2.3GHz i7 with 16GB of RAM: is it enough?

shareimprove this question
 
 
It is most definitely enough. I work perfectly with android studio in a mac thats worse than that. Have you tried reinstalling? – jvrodriguesFeb 28 '15 at 17:08
 
Android studio is well managed, you can use power saving mode if you have less memory. – IshRoidFeb 28 '15 at 17:08
2  
I seem to be having the exact same issue. I'm on a MBP 2014 (Retina) with 8 GB of RAM. I usually end up restarting Android Studio and this seems to fix the issue, but it's not a solution I find soothing, because I waste a lot of time having to do this. I haven't tinkered with any of the VM settings though. I'm on OsX Yosemite btw, so that's also another difference... On my MBP (2011 Non-Retina) with 16GB of RAM I sometimes get a little stutter, but not by as much as on the Retina. – DarwindMar 4 '15 at 12:13
1  
I am working on Yosemite too. I can't remember the name of the latest releases, with animals it was simpler. – Antonio Sesto Mar 4 '15 at 15:13
 
Any new findings you want to share? :-) I haven't tried updating to Android Studio 1.2 yet - have you tried that? – DarwindMar 17 '15 at 14:14

4 Answers

I did the following to resolve the Android Studio slowness.

Go to Android -> Preferences -> Build, Execution, Deployment -> Compiler

Check the Option -

Compile independent modules in parallel (may require larger heap size)

Set VM Options to :

-Xmx2048m -XX:MaxPermSize=512

Restart Android Studio.

shareimprove this answer
 
 
Thanks! That helped a lot :-) – VinayakAug 25 '15 at 7:23
 
its a little bit better...but still getting alot of pinwheels while typing – Tim Boland Sep 8 '15 at 9:37
 
I'm on a 2015 mbp and typing is coming in way slow. I hoped this would help but no avail yet :( – JacksonkrOct 12 '15 at 22:38
 
Worked me very better :) Thanks dude – Shanmugasundharam selvadurai Oct 16 '15 at 7:01
1  
** Thank you all ** I am glad that this helped you. @NaveedAhmad et al – BenJaminSilaJan 13 at 6:11

After understanding of @Benjamin and @Marco Hc, I captured a screenshot and tried to represent the solution graphically. Every number in the picture represents the flow of the solution:enter image description here

  1. Go to Android -> Preferences

  2. Click on Build, Execution, Deployment

  3. Click on -> Compiler

  4. Check the Option - Compile independentmodules in parallel (may require larger heap size)

  5. Check on Use in-processbuild" and "Configuration on demand and clickOK button

  6. Restart Android Studio and that's it.

shareimprove this answer
 
1  
Is Commnad-line Options the same as VM Options? – leonziyoMar 30 at 20:21

It's more than enough, there are some tricks to improve your Android Studio performance:

With these two tricks you'll feel the difference. Let me know.

Cheers!

shareimprove this answer
 

Yes, that is enough computer. I use Android Studio on both my Mid 2011 iMac and my MBP 2.5GHz i7. Android Studio and the emulator are pretty slow to load on the iMac, but I do not have the issues while typing that you describe on either machine.

What version of Android Studio are you using?

shareimprove this answer
 
 
The latest: 1.1.0 - May be the issues are related to some conflicts in the Java configuration, but I cannot figure out which ones. – Antonio Sesto Mar 1 '15 at 9:22



结论:

啰里啰嗦看了这么多,其实结果是git的问题。 我有两个文件夹,A文件夹是IDEA 工程放的代码,B文件夹中放的资源。为了方便修改资源,就把资源文件夹也引入到idea工程中管理(在setting.gradle里面添加配置)

includeFlat 'dy_cike_xcf'
编译的时候,idea的gradle总是检测git有没有残留未commit的东西。我提交代码比较勤快,资源却经常不提交。有大量资源未提交的时候,gradle就一直等待git检测完毕,特别的慢。解决方法就是把资源文件夹下的git库删除,或者在IDEA的git配置中,将B文件夹的GIT库禁用掉。

没有更多推荐了,返回首页