Considering the features it does provides, Android Studio is the best but its worst on a low spec system! Let’s discuss some ways we can speed up Android Studio.
With more 12 million mobile developers in the world, Android Studio sure is promising advanced features for the Android App Developers like Gradle build and much more. But being a powerful IDE, it has its shortcomings too by becoming too heavy for low spec machines.
Android Studio Requirements
The official system requirements (for LINUX) are as :
- 64-bit distribution capable of running 32-bit applications
- For running Android emulator, The same system requirements for Android Studio, but your system must be running a 64-bit processor.
- 3 GB RAM minimum, 8 GB RAM recommended; plus 1 GB for the Android Emulator
- 2 GB of available disk space minimum,
- 4 GB Recommended (500 MB for IDE + 1.5 GB for Android SDK and emulator system image)
- 1280 x 800 minimum screen resolution
Things like disk space and screen is a rare issue, actual limitations occur due to CPU and RAM.
Now let’s try this on a low spec test machine, I have a 64-bit machine running Fedora 26 having Intel core i3 with 3.8 GB RAM.
Following the official instructions for installing android, download the ZIP, extract it on /opt/ for shared users or /usr/local/ for your user.
Having 64-bit Machine, you may need to install some additional libraries:
- If you are running a 64-bit version of Ubuntu, you need to install some 32-bit libraries with the following command:
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386
- If you are running 64-bit Fedora, the command is:
sudo yum install zlib.i686 ncurses-libs.i686 bzip2-libs.i686
After that, through the terminal, move to your recently extracted android-studio/bin/ directory, and execute studio.sh.
For a first install, I simply chose Standard Installation Option. And made a blank activity. With the most compatible 4.0 SDK Level.
And the freezing Starts…
It took a load of time for building Gradle project info. After that, it started freezing multiple times and got stuck in indexing and other gradle related activities.
Setting the gradle
Gradle is a nice tool for managing everything a programmer is usually frustrated by, syncing sources and files. But as much as I have observed, it has the most impact on the speed.
Go to Files > Settings > Build > Gradle and enable Offline Work
Now add a file named gradle.properties in .gradle directory and add the following lines:
This will set default properties for an Android Studio to build gradle resources in parallel and enable Gradle Daemon, a Background process that build quicker (Learn here).
Disable Background syncing
- Go to Files > Settings > Appearance & Behavior > System Settings and Uncheck Synchronize files on frame or editor tab activation
This speeds up IDE by skipping Syncing files every time BUT You’ll have to remember to hit the “Sync Project with Gradle Files” button whenever you make changes to Gradle. (To the left of AVD Manager)
- Go to Files > Settings > Compiler and tick the Parallel Build Option. under command line options add --offline
- Go to Files > Settings > Compiler and Uncheck Make Project Automatically Option.
Also, always clean your project Build > Clean.
Disable Unnecessary Plugins
Idea is check
In File > Settings > Plugins, uncheck all the unnecessary plugins like Github integration etc. I unchecked almost each. Then selected what’s required for gradle. Namely gradle, groovey, junit, and property support, Android support, intelilang.
On applying new plugins settings, it will require a restart.
Use a real device
Android Virtual Device is a nice way to run and test your applications. We also have graphics hardware optimizations, KVM for LINUX and HAXM for windows to optimize it even more.
But, it’s a simple logic, if you are using an emulator, however, optimized it is, it will take a big amount of RAM space. Hence, to run and debug your apps, always test your apks on the smartphone directly. If you are building for android 4.0+ SDK, there is no much compatibility issues and no need to download packages for your test smartphone. Also, we have a nice set of so-called Developer Tools in android settings which make debugging more fun.
An issue I normally get on low spec PC is that gradle shows “no space available on device”, this is simply because of temporary files. Clean up /tmp directory and you are good to go.
Instant Run significantly reduces the build time by simply pushing certain code and resource changes without rebuilding the APK, and in some cases, without even restarting the current activity.
Enable it from File > Settings > Build > Instant Run.
For this, resources related to your test device will be downloaded and installed.
Use power saver option
Enabling File > Power Saver Mode, it disables most of the automated stuff like suggestions, error checking etc making the IDE Faster in real time.
Although Android Studio is nice and has many wizards and automated integration for most of the required stuff, it is indeed heavy. If you are okay compromising some of the easiness, using Eclipse is the best. Even still most of the android tutorials you find are with eclipse. On following the above settings, if the studio works fine, Eclipse will require no changes and would still be faster.
So these were some of the tweaks I used to use Android Studio on a low spec device. More technical Insights are available here. What are you doing other than these? Don’t forget to comment. Happy coding! Until then, keep learning programming from zero at fuddlepixel.com.