Muuzzer
Published in

Muuzzer

Android

Try these tricks to speed up Android Studio

Improve your development time by trying out these neat tricks to control the memory hog Android Studio. Read on!

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 :

Gradle wasting time

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:

macOS activity monitor

See that? It's actively consuming ~5GB of RAM!

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 in 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:

https://www.reddit.com/r/androiddev/comments/7sxhig/android_studio_slower_when_using_kotlin/

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 you're 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

If you’re on Linux, run this command on the 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:

Kill this process using

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 stdio 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 antivirus 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.
  6. 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. Especially 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 optimized quite a lot. I think its a safe upgrade. Why do I keep saying safe and risky? It because sometimes, gradle needs to be upgraded too along with studio and that is risky.

Happy coding!

This was originally posted on Muuzzer.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store