Sometimes it is necessary to have a detailed view on the HTTP requests sent by your Android app and also inspect the responses from the server. With a few steps, it is quite easily possible to do this:
- Connect your Android device and your PC with the same network, e.g. by connecting the PC to the same Wifi.
- On the PC, install Fiddler.
- Make sure, Fiddler is configured to allow remote computers to connect:
If you want, you can user Fiddler also to capture HTTPS traffic:
- In your Android app you have to set your PC as proxy server for the HTTP traffic. To do this, you have to provide the proxy information to the HttpClient by setting a HttpHost instance pointing to your PC’s IP address and the port Fiddler is listening at as proxy in the Http parameters:
HttpParams httpParameters = new BasicHttpParams(); HttpHost proxy = new HttpHost("<your PC's IP>", 8888); httpParameters.setParameter(ConnRoutePNames.DEFAULT_PROXY , proxy); httpClient = new DefaultHttpClient(httpParameters);
Now let Fiddler run on your PC and capture the traffic. Compile your Android app and start it on your mobile device.
That’s it. Fiddler should now show you what’s going on between your Android app and the servers it is connecting.
Your app can’t connect to the server
- Make sure, that the correct IP address is set as proxy.
- Make sure, the PC is reachable from your Android device. E.g. check if the Android device is connected to the same Wifi as the PC
- Make sure, that Fiddler correctly setup the Firewall. Try connecting with disabled firewall.