Categories
Android

How to Debug or Sniff Network Activity on Android Emulator?

Update 2022: proxyman or httptoolkit may be simpler to setup and use on multiple different operating systems than Fiddler. To use the android network TLS interception the device must be connected to the computer and proxyman should be installed on the computer.

Checking network activity is a very important task especially when your app is accessing an API.
However the emulator runs in a virtual environment and hence is often not picked up by default on network sniffing debugging and activity tools.
Fear not we can use Fiddler to view network requests made on your android emulator or even a test device.
Even better we can do this on a linux machine.

How to Install Fiddler

On Windows: Download Fiddler to view network traffic

On Linux (ubuntu):

  1. Install Mono – an open source implementation of the .net framework (basically lets you run .exe on linux)
    sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
    echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
    sudo apt-get update
    sudo apt-get install mono-complete
  2. Download Fiddler for Mono
  3. Run Fiddler
    mono Fiddler.exe
  4. Tools -> Fiddler Options -> Connections -> Make sure Allow remote computers to connect is checked

Set your Emulator or Device to Proxy Traffic to Fiddler

On the device

  1. Go to Settings
  2. Select Wifi
  3. Hold down the wifi connection for 2 seconds
  4. Click Modify Network
  5. set the Following:
    Proxy Hostname: 10.0.3.2 (Genymotion Emulator) | 10.0.2.2 (Normal Emulator)
    Proxy port: 8888
    
  6. Turn Off and On The Wifi to Refresh

Start Debugging

Now your life is made a little bit easier you can check the headers, cookies and form data sent with requests and check responses.

Sources