5 Amazing Tools in Android Studio

5 Amazing Android Studio Tools

Last Updated on March 8, 2018 by Aram

Android studio is an amazing development IDE, that is powered by and built on top of the IntelliJ IDEA Platform by JetBrains.

The studio bundles a good number of amazing tools that serve several purposes ranging between design, resource monitoring, code inspecting, analysis and refactoring, and integrating with different plugins.

These are not the only tools that come within Android Studio, but in the scope of this article, I am only covering these 5 tools.

So the below are some of the amazing tools that come built-in and easily accessed within Android Studio:

 

Vector Asset Studio

Android studio provides you an easy way to import a vector image right into your project’s drawables resource folder.

This is a an amazing way to introduce such resources into your application and reap the benefits of vector graphics.

Using vector graphics can reduce the size of your apk, because the vector graphics can fit any screen density without losing the quality of the image,

To import a vector asset into your project:

  • From your android studio project files, locate the drawable folder , then right click, and then click New
  • Then choose Vector Asset
  • The Vector Asset Studio will open, from there you have 2 options to include vector assets:

Material Icon

There is a big list of predefined material vector icons, you can navigate through these icons that are listed under several categories, the button near the icon label on the vector asset studio will open a screen to let you choose from these material icons.

Note the naming convention that a vector asset will be as the following:

ic_[icon_name]_[icon_color]_[icon_size_in_dp]dp

Whenever you select from any of the predefined material icons list, it will assign a proper naming for the icon.

From Local File (.svg)

You can import any vector drawable into your application, provided that it is of format .svg (Scalable Vector Graphic)

Once imported, you will notice the file that you’ve imported is now represented as an xml file, if you open it, you will see <Vector> tag along with different <path> tags. For example, the below xml represents a vector drawable of an arrow pointing to the right:

 

Android Profiler

android studio profiler

A great resource monitoring tool that displays the realtime usage of CPU, Memory and Network of the app.

Android Profile is the new replacement for the pre Android Studio 3 versions, which was called Android Monitor.

The new Android Profiler tool runs on devices that support an Android  5.0 or above (Api level 21 or above) [Lollipop+]

The Profiler gives the developer the ability to detect critical or abnormal issues in the code, such as memory leaks, infinite loops, heavy usage of the memory, CPU or the Network.

In Android Studio, once you run the application on device, you can click the the profile tab on the bottom navigation bar. It will expand the Profiler panel, and once the apk is installed and the app is launched, it will display a real-time view of the resources usage.

Advanced Profiling

Android Studio 3, introduces advanced profiling feature, that runs by default on Android 8.0 or above (Api Level 26 or above) [Oreo+]

It provides a set of extra monitoring details, such as the number of allocated objects and garbage collection events in the Memory profiler, along with other useful details.

The advanced profiling can be enabled on pre-Oreo devices, by injecting monitoring logic into the compiled app. Goto Run -> Edit Configurations -> Select App Module on Left panel -> Profiling Tab -> Enable Advanced Profiling

Android Lint

Lint, as explained in Wikipedia:

Lint is the common name for visible accumulations of textile fibers and other materials, usually found on and around clothing.

In Android, Lint was first introduced in the Android Development Tools (ADT 16 or Tools 16) , and it could be run separate from the IDE

Though, because of its really wonderful capabilities, Lint now comes fully bundled inside Android Studio.

Android Lint is an amazing tool that helps you improve your code structure and quality.

It can help you by detecting potential bugs, redundant code and issues in formatting or even can tell you if you are using Android Api functions that are either deprecated or not supported by your target Api.

Lint inspections are divided into several categories, the below image explains how does the Lint tool work,  this is from the Android Developer official documentation

The Lint tool uses the lint.xml configuration file to process the source files, and then it outputs the inpsection results distributed within multiple categories.

android lint

You can either run a lint inspection on a single line, a method, a class, or even the whole project.

From Android studio, you can easily access the lint tool’s inspections, through the following steps:

  • Decide which file or folder you wish to run the inspection on. You can choose multiple files and or folders, or even choose the root project folder.
  • Right click on your selection and then choose Analyze , and then you can either choose inspect code or run inspection by name .
  • If you choose the latter, run inspection by name, you will get a small dialog to enter the inspection that you want to run by name, this dialog has auto-complete feature, and it will list the inspections names once you start typing
  • Then you will get a  pop-up  that will ask you to specify inspection scope.
  • Once you confirm your selection, Android Studio will start running the inspection you selected and it will show the progress in the Inspection Results tab at the bottom of the IDE.

You should see the inspection results, as illustrated in the below figure:

Android studio lint inspection results

 

IntelliJ IDEA

IntelliJ IDEA is the powerful IDE that was developed by JetBrains.

In fact, Android studio is built on top of IntelliJ IDEA, according to JetBrains Blog:

IntelliJ IDEA is the base for Android Studio, the new IDE for Android developers

IntelliJ provides intelligent code analysis and insights, which significantly boosts the developer’s productivity and the code quality.

It features code auto-completion, refactoring, data flow and error analysis, code inspections, quick-fixes and many more.

With a massive set of key combinations, you can easily apply any of the amazing IntelliJ IDEA’s features while developing.

Below are some shortcut key combinations that come in handy to easily and quickly access those features of IntelliJ IDEA within Android Studio.

Note: These are based on Windows machine, you might find differences if you work on Mac OS

Android Studio shortcut keys combination

Key Combination Description
Double Shift Search Everywhere
Ctrl + Shift + N Search for File By Name
Ctrl + N Search for Class By Name
Alt + Ctrl + Shift + I Run Lint Inspection By Name
Alt + F7 Find Usages (project explorer file or a class, a method or a variable)
Ctrl + D Duplicate a Line
Shift + Alt + Arrow Up/Down Move a Line upwards/Downwards (This is not specific to IntelliJ Platform)
Alt + Enter Quick Lint Inspection + suggestions
Alt + Insert Generate Code (Constructor,  Get & Set Methods, equals and hashCode, toString, Override Methods and more)
Shift + F10 Run the App (Device or Emulator)
Shift + F9 Debug the App
Ctrl + Shift + T Create a Unit Test for the current Class or Activity. If the class has a test, it will open the associated test file
Ctrl + Alt + L Format code or markup inside a file
Ctrl + Alt + V Generate a variable from an expression in a line of code
Ctrl + Alt + C Generate a constant from expression in a line of code
Ctrl + Alt + F Generate a field from expression in a line of code
Ctrl + Alt + M Refactor a code block into a method, displaying a dialog to name the method and modify the parameters
Shift + F6 Rename with refactor
Ctrl + F6 Refactor a class or method ( this displays a dialog where you can add/delete method parameters or class members along with their access modifiers and data types, and also you can preview your changes before refactoring them)
Shift + Delete delete a line and raise the code up one line

For sure, this is not the whole list of shortcuts, and you might be working with even more keys. It will be great if you can share other shortcut keys in your comment.

Note that the refactor tool of the IDEA platform is powerful enough that it checks every single usage of the refactored method, class, or variable and makes sure that the change is reflected everywhere in your whole project’s code, so you won’t have to care about changing it everywhere by yourself.

And this is one of the great features of the IDEA platform that comes already bundled within the Android Studio.

The JetBrain guys do extremely amazing work, and they totally deserve a credit. You can further read about IntelliJ IDEA and all other JetBrains products.

 

Android Studio Plugins

The plugins tool of android studio allows you to install 3rd part components/tools into your android studio or your app.

You can access the tool easily by going from Android Studio File ->Settings -> Plugins

From there you can install the plugins you prefer.

There is a quick access to only JetBrains plugins, otherwise you can explore all the plugins available from all vendors from the Browse repositories button.

Every plugin shows description and features.

Pick whatever you prefer and install it into your Android Studio.

There are hundreds of Android Studio plugins out-there in the plugins repository. One good example is the fabric plugin. once you install it, you will have easy access to an array of great products that fabric offer, one of them is the Crashlytics

To read more about Crashlytics and how to integrate it into your app, read my article about Android Libraries

Conclusion

Android studio is a great development environment that is powered by and based on the IntelliJ IDEA Platform by JetBrains. The studio offers a range of tools that help the developers boost their productivity, improve their code quality and structure while building bug-free and issue-free applications with the ability to integrate with 3rd party plugins.

In this article I’ve covered 4 of the amazing tools that come bundled within Android Studio; Vector Asset Studio, Profiler, Lint Tool and Plugins.

 

Bonus

Enjoy this amazing 1 hour rendition of Concerti Grossi Op I , by the great Italian Baroque composer Pietro Antonio Locatelli

 

Leave a Reply