Michael Evans

A bunch of technobabble.

Android Studio Tips and Tricks

| Comments

I recently attended Google’s Android Dev Summit where the Tools team presented a talk entitled Android Studio For Experts. The room was packed for the 90 minute session, where a lot of great Android Studio tips were shared. This gave me the idea of showing off some of my favorite Android Studio tips!

Language Injection

Ever needed to type a JSON String? Perhaps you’ve used one as a text fixture for one of your GSON deserializers and know that it’s a huge pain to manage all those backslashes. Fortunately, IntelliJ has a feature called Language Injection, which allows you to edit the JSON fragment in its own editor, and then IntelliJ will properly inject that fragment into your code as an escaped String.

Inject Language/Reference is an intention action1, so you can start it by using +Return, or ++A and searching for it.

Check RegExp

This is pretty similar to the last tip, but if you select the language of the fragment as “RegExp”, you’ll get a handy regular expression tester!

Smart(er) Completion

Now I’m pretty sure most of you have used IntelliJ’s code completion features. Press +Space, and IntelliJ/Android Studio lists options to complete the names of classes, methods, fields, and keywords within the visibility scope. But have you ever noticed that the suggestions seem to be based off the characters you’ve typed, rather than the actual types that are expected in the scope of the caret? Something like this:

Well if you use Type Completion (by pressing ++Space), you will see a list of suggestions containing only those types that are applicable to the current context. In the example below, you’ll only get types that return a Reader, which is the type that the BufferedReader’s constructor expects:

What’s even cooler is that you can press it an additional time, and IntelliJ will do a deeper scan (looking at static method calls, chained expressions, etc.) to find more options for you:

Discovering Your Own Tips and Tricks

Another really cool feature is the Productivity Guide. It shows you usage statistics for a lot of IntelliJ’s features, such as how many keystokes you have saved or possible bugs you’ve avoided by using the various shortcuts. It’s also very helpful for discovering features you might not have known about; you can scroll through the list of unused features to see what you’re missing out on! To find the productivity guide, go to Help -> Productivity Guide.

Bonus Round – IntelliJ 15 Only

Did you know IntelliJ has its own REST client? Super handy for testing out API calls without something like Paw or Postman.

Have any other favorite tips or tricks? Let me know!


  1. Intention Actions are those suggestions in the little popup menus that allow you to quick-fix things like classes that haven’t been imported, etc.

Comments