Using Charles Proxy with Unity3D and Android

April 28, 2017

Tags: , , , , , , ,

I used to use Charles back in the days of Flash dev and found myself missing it trying to diagnose an edge case network issue recently (on a Samsung Galaxy 7) – it allows you to throttle specific requests, as well as map calls to dummy responses, both of which came in handy for the above.

After a bit of tinkering I got it working, here are the steps:

In your Unity project, add the following to the application element in your android manifest:


Create network_security_config.xml in the following folder: Assets/Plugins/Android/res/xml

Contents of network_security_config.xml:

            <certificates src="user" />
            <certificates src="system" />


Disable the MacOS and Mozilla proxy in proxy settings to only see traffic from phone

A quick way to find your ip is to go to Charles and select Help &amp;gt; SSL Proxying &amp;gt; Install Charles Root Certificate on a Mobile Device or Remote Browser. This will give you the proxy ip and port, and the url to grab the security certificate from to install on your phone.

On your phone:
– Go to Settings &amp;gt; Connections &amp;gt; Wi-Fi
– Tap and hold on your Wifi network
– Select Manage Network Settings
– Select Show advanced options
– Select Manual from the Proxy dropdown
– Under Proxy host name, enter the proxy ip address
– Under Proxy port, enter the port (usually 8888).
– Select Save
– On your desktop, you should get a pop up from Charles telling you about a connection attempt. Click on Allow.
– Back on your phone, Open a browser and go to chls.pro/ssl
– You should get a download notification for the certificate. Once downloaded, you should see a pop up asking you to name the certificate (doesn’t matter what you put here). Make sure that VPN and apps is selected in the dropdown and click on ok
– Go to Settings &amp;gt; Lock Screen and Security &amp;gt; Other Security Settings &amp;gt; View Security Certificates
– You should see the certificate you downloaded installed under the User tab (the User and System tabs are the two different certificate types, which relate to the security xml file we created above).

Once this is done, you should see network traffic showing up in Charles.

NB. If you don’t see any traffic, you might need to specify a proxy for whatever you’re using to make requests (I had to do so when using WebClient in Unity).

NB. You don’t want the above to be included in anything but a test build – I’ve added a preprocessor script to my unity build that will add these settings only on local builds when requested, but also runs checks to make sure these settings don’t exist in cloud/release builds.



Your email address will not be published.