What’s New in Android Studio 3

Android Studio 3 was recently released – take a quick tour of what’s new! By Aldo Olivares.

Leave a rating/review
Download materials
Save for later
Share
You are currently viewing page 3 of 3 of this article. Click here to view the first page.

Android Profiler

A very important aspect of an app’s development process is testing. In Android Studio 3, the Android Profiler replaces the old Android Monitor.

You can use the new the Android Profiler to measure CPU usage, Memory and Data usage, and even certain parts of your code execution thanks to the Event Timeline.

In this tutorial you will explore the Network Profiler and the Event Timeline since they are the easiest to understand if you have previous experience with web services.

Network Profiler

Build and Run your app and go to the View/Tool Windows menu and click on Android Profiler.

Tool Windows menu

You can also access it from the toolbar at the bottom of Android Studio 3:
Android Studio toolbar

The Android Profiler will appear at the bottom, where Logcat was showing:
Android Profiler

The Android Profiler has 3 main sections:

  • (1) CPU Profiler: Helps you to monitor your device’s CPU usage by triggering a sample or instrumented CPU trace.
  • (2) Memory Profiler: Helps you to measure your app’s current memory usage by identifying memory leaks that can lead to freezes or app crashes.
  • (3) Network Profiler: Allows you to monitor the network activity of your app such as web requests or mobile data usage

Select your current emulator in the device dropdown:
Device dropdown

Click on Network to open the Network Profiler:
Network profiler

In your app, click on the New Movie button and see what happens in the Network Profiler:
Make an API call
We are going to analyze in detail what happened when you made a request to the NY Times API.

Stop live monitoring by pressing the Live button:
Stop Live monitoring

Use the lower scrolling bar to make the request’s graph easier to see in your network profiler:
Scroll graph

Select the graph by clicking and dragging:
Select graph

A panel will appear with the request’s Name, Size, Type, Status code, Time and its respective Timeline details.
Network call panel

Select the request. Another panel will appear with detailed information about the request sent and the data received:
Request details

Thanks to the Network Profiler you can analyze very deeply what happens when you make a web request. You don’t even need to use external applications to analyze the JSON response.

Take a moment to explore the response data such as the status code, size, json, url, etc.

Isn’t it wonderful how easy it is to analyze web requests with the network profiler?

Yay!

Press the Live button and click on the back arrow to return to the the Android Profiler:
Return to Live

Timeline

The top part of the Android Profiler is the Event Timeline:
Event Timeline

As the name suggests, it helps you to monitor the events that happen during the execution of your app such as touches, rotations, activity states, etc.

Rotate your emulator’s screen using the side controls or by pressing Ctrl + L to rotate left or Ctrl + R to rotate to right. You will notice how your profiler immediately begins to display several changes:
Rotate event

First, you will see the lifecycle states of your MainActivity: saved – stopped – destroyed:
Lifecycle states

Then, the name of the new activity that is currently in the foreground, along with an icon indicating the type of event that triggered its creation(rotation):
Event icon

Thanks to the Event Timeline it is very easy to know what’s going on behind the scenes. But you are not only limited to rotation events, let’s try a couple more:

Press the New Movie button to trigger a touch event:
Touch event

Change the emultor’s volume to trigger a sound event:
Sound event

Exploring all the different events would take way too much time, but I invite you to play around with the emulator to get familiar with them.

If you want to learn more about the Android Profiler, Google has a great article about the subject.

I don’t know about you, but I want to watch a movie before diving into this new Android Development with Kotlin world! :]

Build and Run your app one last time to get a movie suggestion:

Last app run

24 Frames? Sounds like fun!

Let me know which movie you got in the comments below : ]

Where to go from Here

You can download the completed project using the download button at the top or bottom of this tutorial.

If you want to learn more about all the changes in Android Studio 3, I encourage you to read Google’s Official Documentation about the release. It has all you need to know about the new Android development tools at your disposal.

There are many topics that we covered on a high-level like Custom and Downloadable Fonts, Gradle Changes and Adaptive Icons, in order to keep things short and sweet. But remember that you can always refer to our Android Development Tutorials to dig deeper into those subjects

I hope you enjoyed this tutorial, and if you have any questions or comments, please join the forum discussion below!