Inspect network traffic with the Network Inspector

Stay organized with collections Save and categorize content based on your preferences.

The Network Inspector displays realtime network activity on a timeline, showing data sent and received. This lets you examine how and when your app transfers data, and optimize the underlying code appropriately.

To open the Network Inspector, follow these steps:

  1. From the Android Studio navigation bar, select View > Tool Windows > App Inspection. After the app inspection window automatically connects to an app process, select Network Inspector from the tabs. If the app inspection window doesn't connect an app process automatically, you may need to select an app process manually.
  2. Select the device and app process you want to inspect from the App Inspection window.

Network Inspector overview

At the top of the window, you can see the event timeline. On the timeline, you can 1 click and drag to select a portion of the timeline to inspect the traffic.

Figure 1. The Network Inspector window

In the 2 pane below the timeline, select one of the following tabs for more detail about the network activity during the selected portion of the timeline:

  • Connection View: Lists files that were sent or received during the selected portion of the timeline across all of your app's CPU threads. For each request, you can inspect the size, type, status, and transmission duration. You can sort this list by clicking any of the column headers. You also see a detailed breakdown of the selected portion of the timeline, showing when each file was sent or received.
  • Thread View: Displays network activity of each of your app's CPU threads. As shown in figure 2, this view allows you to inspect which of your app's threads are responsible for each network request.

    Figure 2. Inspecting network requests by app thread in the Thread View

From either the Connection View or Thread View, click a request name to inspect 3 detailed information about the data sent or received. Click the tabs to view the response header and body, request header and body, or call stack.

On the Response and Request tabs, click the View Parsed link to display formatted text and click the View Source link to display raw text.

Figure 3. Toggle between raw text (left) and formatted text (right) by clicking the corresponding link

URL url = new URL(MY_URL_EN);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
...
// Sets acceptable encodings in the request header.
urlConnection.setRequestProperty("Accept-Encoding", "identity");

Network connection troubleshooting

If the Network Inspector detects traffic values, but cannot identify any supported network requests, you will receive the following error message:

**Network Inspector Data Unavailable:** There is no information for the
network traffic you've selected.

Currently, the Network Inspector supports only the HttpURLConnection and OkHttp libraries for network connections. If your app uses another network connection library, you may not be able to view your network activity in the Network Inspector. If you have received this error message, but your app does use HttpURLConnection or OkHttp, please report a bug, or search the issue tracker to include your feedback in an existing report that's related to your issue. You can also use these resources to request support for additional libraries.