Blog Infos
Author
Published
Topics
, ,
Author
Published

Posted by: Sherry Yuan

Android Studio is a very customizable IDE, and over the past few years of using it, I’ve discovered a few customizations that made a huge impact on my development speed and enjoyment.

Editor Recommendations
Auto import

Preferences → Editor → General → Auto Import → Select “Add unambiguous imports on the fly” and “Optimize imports on the fly”

New imports get added automatically, and if an import becomes unused, Android Studio will delete it for you.

Show line numbers

Preferences → Editor → General → Appearance → Select “Show line numbers”

Seeing line numbers makes it much easier to navigate and debug code, and discuss code with teammates.

Update color scheme

Preferences → Editor → Color Scheme → General

I find the default error color scheme a bit ineffective. When the error is a single character, looking for the red squiggly underline is like searching for a needle in a haystack. Adding a dark red background color made it much easier to find errors.

You can also import themes that you find online by adding them as a jar file or as an Android Studio plugin.

Keyboard shortcut for “Split Vertically”

Preferences → Keymap → Search for “Split Vertically” and “Unsplit All” → Right click → Click “Add Keyboard Shortcut” → Add shortcut in pop-up window → Click “OK”

Android Studio provides convenient keyboard shortcuts for most common menu actions already, but there isn’t one for “Split Vertically”. I use it all the time when I want to look at another file while working on my current one, for example viewing the XML layout file while I write the Fragment class that uses it. Android Studio’s “Keymap” preference lets you add your own shortcuts. On Mac, I use Command+Option+S for “Split Vertically” and Command+Shift+Option+S for “Unsplit All”.

If you never use “Split Vertically” but you often use other menu options, you can add shortcuts for those instead to speed up your workflow.

Default XML editor mode

Preferences → Editor → Layout Editor

Android Studio defaults to the “Design” editor mode whenever you open XML files, but if that’s not your preferred editor mode, you can choose a different one as the default. I personally like “Split”.

Logcat Recommendations
Make logs colorful

Preferences → Editor → Color Scheme → Android Logcat

By default, only logs at the error level are a distinct color (red) from the rest of the logs (white), but Android Studio lets you customize the color for each log level. This lets you know which level each line of logging is from at a glance, which is great for debugging.

The colors I use are:

  • #FFB7F3 for Assert
  • #A9F6FF for Debug
  • #FF6B68 for Error
  • #C1FFC2 for Info
  • #D4D4D4 for Verbose
  • #FFF2A2 for Warning

Job Offers

Job Offers


    Senior Android Engineer – Big Release Team

    Zalando SE
    Berlin
    • Full Time
    apply now

    Developer (m/w/d) Backend/ Mobile

    Payback GmbH
    Cologne, Germany
    • Full Time
    apply now

    Lead Android Engineer

    ASOS
    London
    • Full Time
    apply now
Load more listings

OUR VIDEO RECOMMENDATION

Behind the Curtains

All smartphones have cameras, and we know we can use specific APIs to get amazing shots. But are they the best cameras? Probably not! What if we wanted to drive an external camera, much more powerful than a smartphone? How would we connect to it, and how would we trigger a shot? This and much more…
READ MORE

Jobs

Configure logcat header

Settings icon on logcat’s left panel

By default, every line in logcat includes a header with the timestamp, process ID, package name, and tag, which makes the logs quite noisy. You can update this to show only the header fields you care about. I usually hide all of them except the tag, since it often has information about the current Activity/Fragment.

Add a custom filter

With the “Show only selected application” filter, logs disappear after a crash if the app relaunches with a new session right after. However, selecting “No filters” means logcat gets very noisy, cluttered with irrelevant logs from other applications.

You can create a custom filter using the “Edit filter configuration” menu, and set it to filter by your app’s package name. With that, only logs from your app will appear in logcat, and they’ll persist across different app sessions.

IDE Performance Recommendations
Disable unused plugins

Preferences → Plugins

According to this Jake Wharton comment, plugins can be extremely useful, but they also noticeably slow down Android Studio. I recommend looking through all your plugins and disabling any you don’t need. For example, I have never used Mercurial or Subversion for version control in my life, so I can safely disable the plugins for them.

Increase IDE max heap size

Preferences → Appearance & Behavior → System Settings → Memory Settings → Select IDE max heap size from dropdown

Android Studio requires a lot of RAM to run smoothly. If you’re getting frustrated with a laggy editor, it’s probably because the default 1280MB heap size is too small for your development. I recommend bumping it up to the 2048MB – 4096MB range, depending on how much RAM your computer has.

Keyboard Shortcuts + Productivity Guide

Help -> Productivity Guide

I recommend taking some time to learn Android Studio’s built-in keyboard shortcuts if you haven’t already. The full list can be found here, and I wrote a previous blog post highlighting the ones I use most often.

Android Studio also provides a productivity guide that displays a list of actions that you use often and the shortcuts associated with them. It’s a fun way to see how much time you’ve saved with shortcuts and learn new ones to save even more time.

Additional Resources

This Android Studio: Tips and tricks talk covers a lot of useful Android Studio features.

Android Studio’s debugger is incredibly powerful, and getting familiar with its more advanced features makes debugging a lot faster. This talk goes over a lot of them.

Tags: Android, Android App Development, Android Studio, AndroidDev, Software Development

View original article at:


Originally published: July 17, 2021

YOU MAY BE INTERESTED IN

YOU MAY BE INTERESTED IN

blog
Nowadays authentication has become common in almost all apps. And many of us know…
READ MORE
blog
Collections are a set of interfaces and classes that implement highly optimised data structures.…
READ MORE
blog
Hi, today I come to you with a quick tip on how to update…
READ MORE
blog

How to animate BottomSheet content using Jetpack Compose

Early this year I started a new pet project for listening to random radio…
READ MORE

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

Menu