Wednesday , 26 April 2017

ANDROID STUDIO FOR BEGINNERS, PART 4: ADVANCED TOOLS AND PLUGINS

1481532169-2509-io-4-plugins-100697513-large

Android Studio offers a rich palette of development tools, and it’s compatible with many plugins. The first three articles in this series focused on basic tools for building simple mobile apps. Now you’ll get acquainted with some of the more advanced tools that are part of Android Studio, along with three plugins you can use to extend Android Studio.

We’ll start with Android Device Monitor, Lint, and Android Monitor–three tools you can use to debug, inspect, and profile application code in Android Studio. Then I’ll introduce you to plugins ADB Idea, Codota Code Search, and Project Lombok.

Debugging with Android Device Monitor

Android Device Monitor is an Android SDK tool for debugging failing apps. It provides a graphical user interface for the following SDK tools:

  • Dalvik Debug Monitor Server (DDMS): A debugging tool that provides port-forwarding services, screen capture on the device, thread and heap information on the device, logcat, process, radio state information, incoming call and SMS spoofing, location data spoofing, and more.
  • Tracer for OpenGL ES: A tool for analyzing OpenGL for embedded systems (ES) code in your Android apps. It lets you capture OpenGL ES commands and frame-by-frame images to help you understand how your graphics commands are being executed.
  • Hierarchy Viewer: A graphical viewer for layout view hierarchies (the layout view) and for magnified inspection of the display (the pixel perfect view). This tool can help you debug and optimize your user interface.
  • Systrace: A tool for collecting and inspecting traces (timing information across an entire Android device). A trace shows where time and CPU cycles are being spent, displaying what each thread and process is doing at any given time. It also inspects the captured tracing information to highlight problems that it observes (from list item recycling to rendering content) and provide recommendations about how to fix them.
  • Traceview: A graphical viewer for execution logs that your app creates via the android.os.Debug class to log tracing information in your code. This tool can help you debug your application and profile its performance.

To launch Android Device Monitor from your command line, execute the monitor program in your Android SDK’s tools directory. If you prefer to run the tool from Android Studio, choose Tools > Android > Android Device Monitor.

You might remember from Part 1 that I used Android Studio to launch my W2A example app in the Nexus 4 emulator. I then launched Android Device Monitor from Android Studio. Figure 1 shows the resulting screen.

1481532169-9770-iop4-figure1-100697471-large

Figure 1. The Devices tab appears when DDMS is selected.

The Devices tab shows all accessible devices, which happens to be the emulated Nexus 4 device in this example. Underneath the highlighted device line is a list of currently visible android.app.Activity subclass objects.

I highlighted the W2A activity object identified by its ca.javajeff.w2a package name, then clicked Hierarchy View to activate the Hierarchy Viewer tool. Figure 2 shows the result.

1481532169-8519-iop4-figure2-100697470-large

Figure 2. The layout hierarchy of the activity screen is shown in the Tree View pane.

Hierarchy Viewer displays a multipane user interface. The Tree View pane presents a diagram of the activity’s hierarchy of android.view.View subclass objects. The Tree Overview pane offers a smaller map representation of the entire Tree View pane. The Layout View pane (whose contents are not shown in Figure 2) reveals a block representation of the UI. See “Optimizing Your UI” to learn more about the Hierarchy Viewer tool and these panes.

 

Comments are closed.

Scroll To Top