Configuring Android Studio

Dmytro Danylyk
Oct 26, 2015 · 4 min read

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?

Image for post
Image for post
Without line numbers
Image for post
Image for post
With line numbers

To do so

  • In toolbar menu select File|Settings
  • Choose Editor|General|Appearance
  • Tick on Show line numbers
Image for post
Image for post
Settings

Camel humps

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

Image for post
Image for post
Without ‘Camel Humps’
Image for post
Image for post
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.
Image for post
Image for post
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
Image for post
Image for post
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.

Image for post
Image for post
Without imports on the fly
Image for post
Image for post
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
Image for post
Image for post
Settings

Android log colors

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

Image for post
Image for post
Darcula theme Logcat highlighting

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

Image for post
Image for post
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
Image for post
Image for post
Holo theme colors

Google Developers Experts

Experts on various Google products talking tech.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

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