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:
- 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.
- 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.
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.
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.
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
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
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.