Tips and tricks to be an effective android developer — part 1 of 3

Azizbek Rasulmetov
4 min readDec 27, 2023

--

The tips and tricks that I will share with you today may help you to be an effective developer. Being an effective developer means that doing something fast and in an easier way, saving your time from boilerplate stuff by using tools and shortcuts.

This includes following tips and tricks:

  • android studio configuration & tips
  • useful plugins
  • handful shortcuts

This article is split into three parts. The first part covers setting up Android Studio, the second part is all about handy plugins, and the last part dives into some super-useful shortcuts.

Configure Android Studio

Configure heap size to increase the performance based on your computer’s RAM 💻

Enable 2 useful features of the AS

Add umambiguous imports on the fly ✈️

While editing the code, automatically add imports when there is only one importable declaration with matching name

Optimize imports on the fly ✈️

Remove unused imports automatically and reorder imports according to the code style in the settings

Exclude Android and Android SDK folders from Antivirus scan

To minimize the impact of the antivirus software on the build speed, exclude android related folders from auto scanning

Some antivirus software can interfere with the Android Studio build process, causing builds to run dramatically slower. When you run a build in Android Studio, Gradle compiles your app’s resources and source code and then packages the compiled resources together in an APK or AAB. During this process, many files are created on your computer. If your antivirus software has real-time scanning enabled, the antivirus software can force the build process to halt each time a file is created while it scans that file.

To avoid this issue, you can exclude certain directories from real-time scanning in your antivirus software.

💡 Caution: To ensure that your computer is safe from malicious software, don’t completely disable real-time scanning or your antivirus software.

The following list shows the default location of each Android Studio directory that you can exclude from real-time scanning:

  1. Gradle cache %USERPROFILE%\\.gradle
  2. Android Studio projects %USERPROFILE%\\AndroidStudioProjects
  3. Android SDK %USERPROFILE%\\AppData\\Local\\Android\\SDK

Android Studio system files

Syntax: %LOCALAPPDATA%\\Google\\**<product><version>**

Example: C:\\Users\\YourUserName\\AppData\\Local\\Google\\AndroidStudio4

(official documentation)

Use Live Templates

This feature of the AS is my time-saver. Live Templates in Android Studio are predefined code snippets or patterns that you can insert into your code by typing a shortcut and then pressing Tab. These templates are designed to increase coding speed and reduce the likelihood of making syntax errors. Android Studio comes with a set of default live templates, and you can also create your own custom templates.

Go to Settings (CTRL + ALT + S) -> Editor -> Live Templates

I added common code patterns of recycler view adapter, Hilt ViewModel and other jetpack compose related code patterns in my live templates.

Here is the example of the HiltViewModel code pattern

@dagger.hilt.android.lifecycle.HiltViewModel

class $NAME$ @javax.inject.Inject constructor(

$PARAM$

) : androidx.lifecycle.ViewModel() {

$END$

}

Everything between $…$ is a replaceable part of the code.

Scratch files

Scratch files are a thing in IntelliJ products. These are throwaway files where you can quickly sketch out ideas.

Scratch Window

The cool thing about these is they evaluate expressions in real-time on the right-hand side of the editor (similar to a Swift playground), so if you are unsure about how a specific function behaves and want to test it quickly without writing a unit test, you can.

I use these a lot for JSON viewing (no need to use json formatter websites)

Scratch file

and for sanity-checking when I’m second guessing an interaction, and they’re also great for quickly demoing an idea to someone in a pairing session.

Create a new one with CMD + ALT+ Shift + Insert (Windows)

Code auto-formatting

You can turn on auto code formatting that will reformat your code according to the code style in the settings and optimize imports via actions on save in the settings.

You can choose whether to format the changed lines or changed whole file from the drop-down.

That’s it for the 1st part of the article series.

If you like my article, please don’t forget to click 👏👏👏 & to share it with others.

Also, to be notified about my next articles and stories, follow me on Medium.

In the next post we’ll explore IDE plugins! Give it a read:

--

--