Configuring Fiddler To Be A Proxy For Android Emulators In Eclipse
- 03 Apr 2013
I struggled with getting Fiddler to work with the emulators shipped with Eclipse. Here is a quick reference for you to get Fiddler installed so you can debug HTTP and HTTPS traffic.
Install and configure Fiddler
Install Fiddler from this link: http://fiddler2.com
Start Fiddler (Windows Key then type Fiddler if you cannot find it on your start screen) if Fiddler is capturing data hit F12 to stop capturing
Go to the Tools menu and choose Fiddler options… to get the dialog below. Configure each of the tabs in the dialog shown to match the screenshots below. For details on these settings go the Fiddler website, help or better yet buy the Book!
Click on the Stream tool bar icon to activate this (it will bypass any breakpoints etc… you may have previously defined:
Pick a device for the emulator and configure it
First choose a device and ensure it runs
Start the Android Virtual Device Manager and go to the Devices tab and select your device or create a new AVD from the Device Definitions:
I am going to create a new Nexus S and hit Create AVD… to create a new one. Then highlight and Start the device by hitting the Start… button:
(Even on my hopped up system it takes forever for the emulator to come all the way up). Then when I tried to load a web page it would just hang!
I took a look at the configured RAM (hit the Edit… button in the AVDM above):
and then amount of RAM used by the emulator and saw it looked like I was maxing out the memory by visiting web pages.
I stopped the emulator and changed the RAM to 768 in the Memory Options and that solved the problem!
Configure the device to use the Fiddler Proxy
Hit the OK button to dismiss the intro screen and hit the center of the circle and choose the Settings app:
Then choose the more… option then Mobile networks:
then Access Point Names and select your APN:
You will now set the Proxy and Port settings for this APN:
Find the IP address of your computer by hitting the Windows Key and R key at the same time and typing cmd. Then hit enter. This will open a Command Prompt window. Type ipconfig in the command window to list your network configuration:
There is a lot of information in here! Ignore any addresses that start with 169. and look for IPv4 addresses. In my case the IP address of my card is 192.168.1.6 (note this and close the window).
Enter the IP address you got above as the proxy and the port from Fiddler (8888 by default) for the Proxy and Port values in the APN settings on the device
Hit the Back button or Home button in the emulator controls to go back and see if you can capture traffic by starting the browser.
You should get this error if everything is working correctly and have tried to navigate to the default google https site in the browser (NOTE: If you get a connection error your anti-virus or firewall is probably blocking the 8888 port so your device cannot communicate with fiddler. Configuring this is beyond the scope of this blog post):
This is because Fiddler uses a Man in the Middle approach to decoding https traffic. You have to install the Fiddler certificate on this device now. This is pretty easy! Simply navigate to your Fiddler proxy and port in the browser and point to the certificate by typing in something similar to this in the browser address bar (substituting the ip address you used above for the proxy setting): http://192.168.1.6:8888/FiddlerRoot.cer
You will get this dialog:
Give the certificate a name like Fiddler and hit the OK button.
You will get this message:
So hit OK and create a PIN for your device (don’t forget it).
A brief confirmation that the Certificate was installed will appear and you are now all set to debug HTTP and HTTPS traffic on your emulator!
If you go back to Fiddler you will see you are not capturing the HTTP and HTTPS traffic from the device! You do not have to capture the traffic by hitting F12 because as a proxy the traffic will appear by default in the Web Sessions window.
Let me know if this was useful to you!
<< Go Back