We all have been there. This journey of patience endurance starts from the moment you click on that dreaded Android Studio icon.

And obviously we cannot forget the classic :

Once my build time was 45 minutes! Yeah not kidding! That was a bad bad day for me.

It is a well known fact that Android Studio has a huge appetite for memory. It literally eats RAM for breakfast. This is the state of my computer with android studio running:

See that? Its actively consuming ~5GB of RAM!

macOS activity monitor

So yeah, we all have been there, pulled a lot of hair, cursed at our IT department to not give the Super Computers that we deserve. Anyway, that is not the point here. The developer community has been quite active at finding out solutions. I’ll post some of the options I’ve managed to get online. Here they are:

Disable Useless Plugins

This goes without saying, each plugin you install adds to the startup time and memory usage. And this has been posted by Jake Wharton himself (Link to post)

Open Preferences -> Plugins and disable the following:

1. Android APK Support

2. Android Games

3. Android NDK Support

4. App Links Assistant

5. Editor Config

6. Any Language plugins

7. Firebase [ all plugins]

8. Google * – all of them

9. Intellij Configuration Script

10. Mercurial Integration – If your using GIT

11. Subversion – if you’re using git

12. Test recorder

13. TestNG-J

14. YAML

15. Settings repository

16. Copyright

17. Genymotion – if you’re using the latest emulator which is much better now

Increase Gradle Heap Size

If you have good ram configuration in your PC, then increasing Gradle heap space helps:

org.gradle.jvmargs=-Xmx4096m

Gradle build getting stuck sometimes

Sometimes gradle seems to get stuck and takes forever even though you might have ran a build a few seconds ago. Your computer CPU usage goes 100% and the fans start whirring. Thats the indication, it’s stuck officially.

If you’re on linux, run this command on terminal to find out the gradle process:

ps -ef | grep java | grep ./gradle | grep Android

It will print the process and it should end with something like org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.4.1 (depending on your gradle version)

This was my output:

Time to kill that process.

Kill -9 78058 (process id)
Immediately Android Studio will pop a message saying Gradle has crashed. Trust me it’ll save you a lot of time. Re-start your build and now it’ll be much faster.

Adjust your Android Studio memory settings

Appearance & Behavior -> System Settings -> Memory Settings

Tweak these settings accordingly. Sometimes allocating too much heap is also bad. It’ll result in studio slowing down after prolonged usage.

Some more suggestions for better studio performance:

1. Try and use android studio on a linux machine. Works better

2. Android studio needs 8 GB ram or more to function properly. I suggest go for 12GB for a smooth experience

3. Disable your antivirus or mark the development and android studio folders in your anti-virus as safe/add an exception so that it does not keep scanning again and again. Compiling and building deletes and creates a lot of files. In such cases, the anti-virus kicks in because of the increased I/O

4. Replace your HDD by an SSD.

5. Don’t install any theme or color scheme if you don’t have a good config computer.

Never Upgrade Gradle version without reading about it online no matter how many times Android Studio prompts you to

DON’T upgrade your grade version without reading about it online. Specially if you’re working on a legacy production code. I once wasted my whole day trying to solve the issues. Unless you started a new project, keep upgrading *each time* it prompts. Like that, it won’t have issues. But if you’re upgrading after a long time, inform your boss that today you’re not going to be coding 🙂

Upgrade to latest Android Studio (Risky)

The latest Android Studio 3.5.3 has been optimised quite a lot. I think its a safe upgrade. Why I keep saying safe and risky? It because sometimes, gradle needs to be upgraded too along with studio and that is risky.