Setting up Charles as SSL proxy for Android 8 Emulator (AVD)
If you are an iOS developer, I’m pretty sure that you know how to set up Charles as SSL proxy for iOS simulator. But if you use AVD or physical Android device, it is a bit complicated because Charles doesn’t have 1-click SSL certificate installing feature for Android devices. So we have to set the certificate up manually, let’s do it:
Setting up the computer which runs Charles
- Enable HTTP Transparent proxying and set the port number
Menu -> Proxy -> Proxy Settings

- Set the SSL proxying locations
Menu -> Proxy -> SSL Proxying Settings
Check the Enable SSL Proxying, and then click add button to add a new location.
If you’d like to intercept all of the SSL connections, just set * for Host and Port.

- Set up the white list
Menu -> Tools -> White List
Click Add to add a new location. Select the https as the Protocol, and leave other fields as blank, then it will allow all https connections

Setting up the Android Emulator (AVD).
- Setting up the proxy ip and port for AVD
Do not use
localhostas the proxy ip setting, if you set localhost for AVD, the AVD would regard it as itself, not the computer which runs the Charles, so need to use the real ip address of your computer all the time.
Start an AVD instance -> click ... button on the right side of the AVD screen.

Go to Settings tab, and then click Proxy tab on the top of the window, then set your computer’s IP address and Charles’ port.

- Install Charles SSL Certificate
open the URL http://chls.pro/ssl with Chrome in AVD, then the browser will download the certificate, after that you can assign a name for the new certificate.

The system may ask you to setup a PIN at this stage.
Done!
Try to access google(https://www.google.com) to see if it works correctly.
Important
If you prefer to use Charles debug your own app on the Android which is ≥ Android 7.0 (API level 24), please read the 2nd part
Follow me at medium if you like this post ;-)
