I use Charles proxy to debug my network traffic. This requires setting the device or emulator proxy to point to my local ip address where Charles is running. Charles can then intercept the device’s network traffic. This post outlines how to set the proxy for android devices and emulators.
Go to your wifi settings and long tap on your wifi network until you see a menu.
- Select Modify Network
- Tap Advanced Options
- Select Manual under Proxy
- Enter your local ip and the proxy port
- Select Save
The process for Genymotion emulators is the same as the steps above for real devices, with one handy variation. If you use 10.0.3.2 for the ip address, this will automagically refer to your computer’s local ip. This means that you won’t need to update it when your ip address changes e.g when you decide to work from a cafe for a couple of hours.
The proxy for Android emulators can be set from the command line with the following argument:
There used to be a setting for adding command line options in Android Studio but this has disappeared. You can still run the option when launching the emulator from the command line.
Start by listing your emulators to find the name of the one you want to launch:
android list avd
Now launch the emulator
emulator -avd <name> -http-proxy http://<local-ip-address>:<port>