I use Charles proxy when developing any Android app. I permanently have Charles open and the Android device that I’m running/testing the app on proxying through Charles. Usually I use a real device to test on, mainly because the Google emulators are a pile of crap. But recently Google have been making efforts to improve the emulator, so I’ve started using it more.
This is really a note to myself about how to setup the emulator to work with Charles. First off, don’t start the emulator from Android Studio, start it from the command line using this command:
emulator @Nexus_5X_API_23 -http-proxy http://192.168.1.82:8888 &
This starts the emulator named ‘Nexus_5X_API_23′ using the emulator command (in the sdk tools folder). And uses the proxy IP address and port given. Also, note the ‘&’ on the end to run the command in the background, otherwise the terminal window will be locked up by the emulator.
If you’re using the fantastic Genymotion emulator, it’s even easier to setup the proxy – it’s almost like setting it up on a real device. On the emulator click on Settings then Wi-Fi. You should see the wi-fi named ‘WiredSSID’. Long click on this to popup the menu, and click on Modify network. Click on Advanced options and change the proxy to manual. Set the proxy to 10.0.3.2 (Genymotion’s address for the local network) and the port to 8888, then save.
If you want more details on setting up Charles, e.g. SSL proxying, let me know and I’ll write a full post on it.