Sunday, March 23, 2014

Debugging Android HTTP traffic with Charles Proxy and Genymotion emulator

Genymotion ( is a great tool for debugging your Android code.
It is much faster than the Android emulator as it is based on x-86 native code, and unless you really do some low level work, is indistinguishable from a real device. It actually is faster and smoother than most devices, so make sure you also test on real devices...
Anyway, it became an important tool for me while developing. Highly recommended!

Occasionally you need to debug HTTP calls (to web sites, or more often to server API end points), and for that an HTTP proxy as Charles ( is another great tool. Its paid version already returned its cost 10 fold for me...

So, first you will need to setup charles on your Mac as the proxy for the emulated Android machine. The key is to know the local mac IP is and the default port for the proxy is 8888 (if you have not played with Charles settings).
Detailed instructions for setting the proxy on the Android virtual machine in Genymotion are available here:
And repeated for your convenience
  • In your Genymotion Android emulator…
  • Settings -> Wifi -> Press and hold your active network
  • Select “Modify Network”
  • Select “Show Advanced Options”
  • Select “Proxy Settings -> Manual”
  • Set your Proxy to: (Genymotion’s special code for the local workstation)
  • Set your Port to: 8888
  • Press Save
Now, this worked fine as long as I was using unencrypted http, but if you need to work with SSL encrypted APIs and need to get the clear data to debug your stuff, you can set Charles to provide the SSL certificate.
To do that you need to follow these instructions (the instructions are available here: between the "brakertech" answer and "bkurzius: answer):
  1. Install fully licensed charles version
  2. In Charles, goto Proxy -> Proxy Settings -> check “Enable Transparent HTTP Proxying”
  3. Proxy -> Proxy Settings -> SSL TAB -> check “enable SSL Proxying”
  4. Add your host to the list of Locations (e.g. with port 443
  5. Download the Charles certificate here:
  6. unzip the certificate, and then send it by email to your emulated device (or make it available for download from the emulated device browser).
  7. When you get it on the device and open it, you will be able to install it by giving it a name. Depending on the Android OS version, you may need to first set a screen lock PIN or password
 Once the certificate is installed, you can intercept encrypted SSL traffic using Charles.

And a message from our advertisers:

Toptal provides remote engineers and designers of high quality. I recommend them. Follow this link (full disclosure: this is my affiliate link):

Friday, January 3, 2014

Setting up a local Google App Engine Development Environment for Python

Installing Google App Engine Dev. Environment

I have a mac running latest OSX 10.9 Mavericks. I want to be able to develop and test a Python Google App Engine app on this machine. This is the list of steps I took to make it happen. I am starting from a fairly clean machine as my older mac have multiple installations of Python, and I seem to get stuck attempting to setup my dev environment on it.

I placed this list here, as some of the documentation around the web is scattered and sometimes confusing or outdated. This was done on OSX Mavericks.

Some of the steps below are specific to my own app (pycrypto, PIL and lxml may or may not be needed by your app).

1. Python is installed by default (version 2.7.5 is bundled with OSX)
2. sudo easy_install pip
3. Install XCode from App Store
4. Install XCode command line tools: xcode-select --install
had to use the ./configure --with-ssl=openssl command and not ./configure as mentioned
6. install setuptools: wget -O - | sudo python (
7. install PIL: sudo pip install Pillow
8. install Crypto (used by my app): sudo pip install pycrypto
9. install lxml (used by goose): sudo pip install lxml (if fails, you can try: sudo apt-get install python-lxml)

UPDATE: had to install libjpeg: sudo apt-get install libjpeg-dev which forced me to re-install Pillow


Cleaning Up My Old Mac Python

Ok, now that I have the app engine development environment setup on a new mac, and some test scripts running fine, I am going to clean up my old mac (which is actually my work machine - a Mid 2012 Mac Book Air 13” with OSX 10.9.1).

My understanding is that I can remove any installations that are under /Library/Frameworks/Python.framework.
I want to be left with the Apple installed python 2.7.5 which is under /System/Library/Frameworks/Python.framework

So, I am following the link suggested in the above SO answer:
It seems a bit radical, but after looking into what I got from running the list of files, it seemed to be fine. So I just did that and deleted all the directories and files listed under /Library/Frameworks/Python.framework various old versions, the Applications folder and the Receipts folder.
Finally, I made a symbolic link to the Apple python from /Library/Frameworks by:
cd /Library/Frameworks
then (just to be on the safe side):
sudo mv Python.framework Python.framework.orig
and then
ln -s /System/Library/Frameworks/Python.framework/ Python.framework

Next, I changed the python in the GAE Launcher preferences to /usr/bin/python2.7 and Voila!
All is well, and I can move on to do the tests here.

Tests are running on my local machine.