Proper and fast debugging is a key to any application development. Unlike my great experience with PHP where I usually debug whatever I need in a breeze, I found my self against the wall when working with Android and web service API calls. Problem is simple, you cannot that easily dump entire $_SESSION array like in PHP and see it’s content. Surely there are other ways as Java language has full set of it’s own debugging ways.
Here I’ll give you some practical guide on how you can really, down to the great detail test your API calls in Android. Get ready because we are going down to the network level. First of all, I’m using Windows 7 machine here, but fear not, all that is demonstrated can be used on the Linux machine as well, just with different tools.
So, the general idea is to set your PC/Laptop WiFi connection to serve as a HotSpot on which you will connect trough your Android phone. This way all network traffic from your phone goes trough your computer. And then, all you need on your computer is software like Windows Network Monitor to monitor all your HTTP traffic and you can see all of the requests and responses in great details. For me, this approach was a savior as it enabled me more fast debugging of web service API calls trough my Android app.
So here it is in a few simple steps:
- Download and install Microsoft Network Monitor (or WireShark, which is also great tool).
- Download and install Connectify.
- Using Connectify setup your PC to act as a HotSpot.
- Connect your phone to the HotSpot on your PC.
- Start your Microsoft Network Monitor (or WireShark, or some XYZ tool).
- Start your application on Android phone and monitor the HTTP traffic.
Additionally, in my case where I used MS Network Monitor I setup the filters like:
HTTP AND ((Source == “192.168.2.101″ AND Destination == “some-api.domain”) OR (Destination == “192.168.2.101″ AND Source == “some-api.domain”))
This enabled me to specifically filter out the traffic between my Android app and the Webservice API I was calling.
Having an insight into the raw HTTP request response is far more informative then debugging individual Java objects like HttpPost, HttpResponse, HttpEntity (at least it was for me).
As an example, here is a sample of request:
Frame: Number = 283, Captured Frame Length = 199, MediaType = WiFi
+ WiFi: [Unencrypted Data] .T….., (I) RSSI = -40 dBm, Rate = 54.0 Mbps
+ LLC: Unnumbered(U) Frame, Command Frame, SSAP = SNAP(Sub-Network Access Protocol), DSAP = SNAP(Sub-Network Access Protocol)
+ Snap: EtherType = Internet IP (IPv4), OrgCode = XEROX CORPORATION
+ Ipv4: Src = 192.168.2.101, Dest = 46.137.*.*, Next Protocol = TCP, Packet ID = 12297, Total IP Length = 135
+ Tcp: Flags=…AP…, SrcPort=32886, DstPort=HTTP(80), PayloadLen=83, Seq=499775385 – 499775468, Ack=2775527642, Win=32044
- Http: HTTP Payload, URL:
– payload: HttpContentType =
HTTPPayloadLine: {“id”:0,”method”:”getActiveCities”,”params”:["tlrg9507bl9tm6lu899vg90115","de_DE"]}
And here is a sample of response captured from network monitor:
Frame: Number = 285, Captured Frame Length = 805, MediaType = WiFi
+ WiFi: [Unencrypted Data] F……, (I)
+ LLC: Unnumbered(U) Frame, Command Frame, SSAP = SNAP(Sub-Network Access Protocol), DSAP = SNAP(Sub-Network Access Protocol)
+ Snap: EtherType = Internet IP (IPv4), OrgCode = XEROX CORPORATION
+ Ipv4: Src = 46.137.*.*, Dest = 192.168.2.101, Next Protocol = TCP, Packet ID = 14634, Total IP Length = 741
+ Tcp: Flags=…AP…, SrcPort=HTTP(80), DstPort=32886, PayloadLen=689, Seq=2775527642 – 2775528331, Ack=499775468, Win=31
- Http: Response, HTTP/1.1, Status: Ok, URL:
ProtocolVersion: HTTP/1.1
StatusCode: 200, Ok
Reason: OK
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
+ ContentType: application/json
Date: Fri, 10 Jun 2011 15:14:37 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: Apache
Set-Cookie: PHPSESSID=tlrg9507bl9tm6lu899vg90115; path=/
ContentLength: 345
Connection: keep-alive
HeaderEnd: CRLF
– payload: HttpContentType = application/json
HTTPPayloadLine: {“result”:[{“cityId”:”239″,”name”:”Sofia”},{“cityId”:”266″,”name”:”Blagoevgrad”},{“cityId”:”296″,”name”:”Burgas”},{“cityId”:”294″,”name”:”Varna”},{“cityId”:”299″,”name”:”Veliko Tarnovo”},{“cityId”:”295″,”name”:”Plovdiv”},{“cityId”:”298″,”name
As you can see, in my case I was playing with JSON web service, calling it from Android app.
Hope this article will give you some ideas on debugging your Android apps.








Great article!
P.S. Link to connectify doesn’t work