Intro

Android Studio has a cool feature to Import and Export settings. So during installation of new Android Studio version I usually import my previous settings. But recently a bad thing happened to me - I have lost my Android Studio settings file.

My advice to you: always keep a backup of your Android Studio settings files somewhere on the cloud.

And since I am configuring my Android Studio from scratch anyway, below are some things which may be useful for you.

Show line numbers

When I first fired up Android Studio and started using it, one of the first things I wanted to do was to be able to see line numbers within the file. I was always curious why this thing is not turned on by default?

Without line numbers

With line numbers

To do so

In toolbar menu select File|Settings

Choose Editor|General|Appearance

Tick on Show line numbers

Settings

Camel humps

Android Studio doesn’t respect ‘Camel Humps’ words when you navigate through your code with pressed Ctrl+Left/Right arrow keys.

Without ‘Camel Humps’

With ‘Camel Humps’

To do so

In toolbar menu select File|Settings

Choose Editor|General|Smart Keys

Tick on Use ‘Camel Humps’ words

Settings

Note: if you still want to select the whole word on mouse double click go to

In toolbar menu select File|Settings

Choose Editor|General

Remove tick on ‘Honor Camel Humps words settings when selecting on double click’

Field naming conventions

If you want to follow field naming conventions from Android Code Style Guidelines for Contributors first read Jake Wharton’s article — Just Say mNo to Hungarian Notation. Still, there is one thing which Android Studio can automatically do for us - generate field name prefix for:

Non-public, non-static field names start with m .

. Static field names start with s.

Field name prefix

To do so

In toolbar menu select File|Settings

Choose Editor|Code Style|Java

Select Code Generation tab

Add m prefix for field and s prefix for static field

Settings

Private member access between outer and inner classes

There is one inspection in Android Studio that I think should be turned on by default:

In toolbar menu select File|Settings

Choose Editor|Inspections

Tick on Java|J2ME|Private member access between outer and inner classes

This inspection will help you to decrease methods count, achieve greater performance and less use of memory. If you want to know more just read inspection description and Jake Wharton’s talk — Exploring Java’s Hidden Costs.

Imports on the fly

In Android Studio there are shortcuts to auto import or clean-up none used imports. But we live in 2015 right? Those things should be done on the fly.

Without imports on the fly

With imports on the fly

To do so

In toolbar menu select File|Settings

Choose Editor|General|Auto Import

Tick on Optimize imports on the fly

Tick on Add unambiguous imports on the fly

Settings

Android log colors

With default Darcula theme Logcat highlighting I am not able to recognize type of log.

Darcula theme Logcat highlighting

I prefer to use bright colors from plain old Android Holo theme.

Holo theme Logcat highlighting

To do so

In toolbar menu select File|Settings

Choose Editor|Colors & Fonts|Android Logcat

Click on Save As… button and create new color schema

Change all colors to ‘Holo theme colors’ (Uncheck ‘Use inherited attributes’ for every color)

Assert: #AA66CC

Debug: #33B5E5

Error: #FF4444

Info: #99CC00

Verbose: #FFFFFF

Warning: #FFBB33