How to Add external library in Android studio

The reason of this article, is to list helpful Android Studio shortcut key that will improve your overall efficiency and performance.
There are obviously many many more optimizations, shortcuts etc., but for sake of keeping this article short, I limited it to a sum of 28 points.
Hope you will enjoy it!

Visual

Material Colors theme for Android Logcat

To change Android Studio Logcat you need to go to: Preferences (Settings on Windows / Linux machines) → Editor → Colors & Fonts → Android Logcatand change the foreground color for every type of log.

My material colors:

  • Assert #BA68C8
  • Debug #2196F3
  • Error #F44336
  • Info #4CAF50
  • Verbose #BBBBBB
  • Warning #FF9800

Prevent Android Studio Logcat from clearing the log for the current application when it crashes.

To do that you need to go to the Android Monitor panel and choose Edit filter configuration on the right side dropdown.

Apply a proper code style to your IDE (IntelliJ / Android Studio).

Go to Preferences → Code Style → Java and in a Scheme dropdown you can choose your code style (or set up a new one).

2 styles which are especially worth to mention:

Use split screen for increasing efficiency.

To turn this feature on, you need to right mouse click on the tab of your main screen and choose Split Vertically / Horizontally feature.

But to be as efficient as possible we need to set up a custom keyboard’s shortcut. To do that go to Preferences → Keymap and search for Split Vertically. Then open a context menu and click Add Keyboard Shortcut.
In my case, for vertical split view I added control + alt + v.
It is shown on a gif below. You can define the shortcut for a horizontal split view as well.

Distraction Free Mode.

You can enable it by going to: View → Enter Distraction Free Mode

In the distraction-free mode, the editor occupies the entire IntelliJ IDEA frame, without any editor tabs and tool-window buttons. The code is center-aligned. [IntelliJ Idea Viewing Modes]

Use Live Templates

  • you can use a shortcut: cmd + j (Windows / Linux: ctrl + j).
  • you can use many already defined templates, like for Toasts or ifconditions.

Shortcuts and helpful commands

The best and the most helpful command is Search for command:

cmd + shift + a (Windows / Linux: ctrl + shift + a).

Let’s say you want to close current tab and you don’t know how. You just type: close and you’ll get a proper shortcut / command.

Choose from the last copy / pastes (manage your clipboard):

cmd + shift + v (Windows / Linux: ctrl + shift + v).
By default there are 5 last copy/paste items.

The depth of the Clipboard stack is configured in the Limits section on the Editor page of the Settings dialog box. When the specified number is exceeded, the oldest entry is removed from the list. [Cutting, Copying and Pasting in IntelliJ IDEA]

Enable multicursor feature:

control + g (alt + j for Windows / Linux).

A detailed article about this feature is provided by Bartek Lipinski on Medium. Highly recommended!

Open a class:

cmd + o (Windows / Linux: ctrl + n).

Open any file:

cmd + shift + o (Windows / Linux: ctrl + shift + n).

Open symbol:

cmd + option + o (Windows / Linux: alt + shift + n).

Go to implementation:

cmd + option + b (Windows / Linux: ctrl + alt + b).
Let’s say you have an interface. By clicking on the interface’s name and then clicking the Go to implementation shortcut, you will be redirected to classes which implement that interface.

Go to declaration:

cmd + b (Windows / Linux: ctrl + b).
It allows you to quickly check and go to a declaration of a class, method or a variable.

Go to type declaration:

control + shift + b (Windows / Linux:
ctrl + shift + b).
Let’s say you defined:

Employee employee = new Employee(“Michal”);

When your caret is on employee and you click the shortcut, you will be redirected to the Employee class.

Go to super:

cmd + u (Windows / Linux: ctrl + u).
For instance, you override some method. When your caret in on the method’s name and you click Go to super shortcut, you will be redirected to the parent method.

Move between tabs:

cmd + shift + [ (move left) or cmd + shift + ](move right) (Windows / Linux: alt + ← / →).

Move between Design / Text tabs in layout’s view:

control + shift + ← / → (Windows / Linux: alt + shift + ← / →).

Close a current tab:

cmd + w (Windows / Linux: ctrl + F4).

Hide all windows:

cmd + shift + F12 (Windows / Linux: ctrl + shift + F12).

Minimize Android Studio instance:

cmd + m (Windows / Linux: ctrl + m).

Format your code:

cmd + option + l (Windows / Linux: ctrl + alt + l).

Auto-indent lines:

control + option + i (Windows / Linux: ctrl + alt + i).

Implement methods:

control + i (Windows / Linux: ctrl + i).
Let’s say you implement an interface. Then, you can quickly import all methods provided by that interface, just by clicking this shortcut.

Smart code completion

filters the list of methods and variables by expected type

control + shift + space (Windows / Linux: ctrl + shift + space).

Find:

cmd + f (Windows / Linux: ctrl + f).

Find and replace:

cmd + r (Windows / Linux: ctrl + r).

Move hardcoded strings to resources:

option + return (Windows / Linux: alt + enter). The shortcut must be used when a caret is on a text. Check the gif below:

If you use that shortcut globally, the IDE will do Project quick fix (show intention actions and quick fixes).

Build and run:

control + r (Windows / Linux: shift + F10).

If you like my article, please don’t forget to comment us.

By Tell Me How

It is a technology blog and admin has excellent experience in programming from 5+ year. You can contact us at ceo.tellmehow@gmail.com

Share your thoughts

Leave a Reply

Loading Facebook Comments ...
Loading Disqus Comments ...