Blog

Android emulator – proxy and custom domain

So, I wanted to be able to use a proxy while developing my android app. Also I am using a custom domain set in my hosts files.

Here I am using Charles, but any should do really.
So in the Android emulator go in Settings>Wireless and networks>Mobile Networks>Access Point Name. You will see one named Telkila.
Edit it and change the proxy to be 10.0.2.2 (which is in the emulator the address of the machine running the emulator). Set the port to be the port you are proxying on (in Charles by default it is 8888).
And voila. If you open your web browser you should see queries.

Now, what about having a localhost with a set up domain being for instance mydomain.localhost.
Well in Charles you have a map remote option. So just add one with the value

Protocol: http
Host: 10.0.2.2
Port: 8888

to

Protocol: http
Host: mydomain.localhost
Port: 80

and in your app the remote URL should look like for instance

http://10.0.2.2:8888/index.php

and charles will map this to

http://mydomain.localhost/index.php

and voila :)