You can configure Android devices to connect to your local machine to test sites or apps using a proxy like Charles.

Set up Charles

Open Charles and go to Proxy > Proxy Settings. Under 'Port', enter a port number which will be used on your device.

Charles proxy settings

Emulator

Set up an Android Virtual Device (AVD) through Android Studio: Tools > Android > AVD Manager > Create Virtual Device. Make sure you remember the name of the device, since you'll need this when running the emulator.

Set up an Android Virtual Device

Android Studio claims to have a Proxy option once the emulator is open, but that doesn't seem to exist in my version. Instead, you can run the emulator from the command line and pass a proxy option. From the Android SDK folder (wherever you installed it on your machine), run

tools/emulator -avd Nexus_6P_API_23 -http-proxy 192.168.0.24:9999

The -avd option needs to match the Name column in the AVD manager, with spaces replaced with underscores. The -http-proxy option takes your local IP address along with the port set in Charles - all internet traffic should now go through Charles running on your machine. If you close Charles then the internet on your emulator will fail.

Run emulator with proxy param

Android Device

To use a proxy on an actual Android device, make sure the machine running Charles and your Android device are on the same network. Then, on your Android device, open Settings > WiFi > Long-press on the current network > Modify Network. In the dialogue which opens, change 'Proxy' to 'Manual', then enter your machine's IP address along with the port being used by Charles and save.

Again, if you close Charles then the internet on your Android device will stop working, so remember to turn off the Wifi proxy on your device.

Update Android wifi proxy settings