Search code examples
androidadb

Android: Monitor network traffic of apps, using similar tool to F12->Network on Web


In Web development it's well known that inside the Dev console->Network tab it's possible to read, for example, Json's traffic between the client and server.

What about similar tool for Android apps? Is something like this achievable: Connecting device on debug mode to ADB, and see the web traffic? For example to read in live how App X receiving Json from her back-end server? (And similar to Web - Read this Json...)


Solution

  • You can use a Debugging Proxy like Charles: http://www.charlesproxy.com/ This is in my opinion the best option for network inspection because it gives you a lot of advanced options such as:

    • Replaying requests
    • Simulating slow network speed
    • Setting up breakpoints where you can edit the response from the server before it hits your app

    The only downside is that it can be a little tedious to set up, and you have to edit your phone/emulator Wifi settings a lot...

    You can also add a debugging library to your app, like Stetho by Facebook: http://facebook.github.io/stetho/

    This will let you observe the network requests made by your app in the Chrome Dev Tools amongst other thing (inspecting your layouts on screen, read/write DB and Shared Preferences access...)