Proxy which requires authentication with Android Emulator

Viewed 75697

Has anybody managed to get the Android Emulator working behind a proxy that requires authentication?

I've tried setting the -http-proxy argument to

http://DOMAIN/USERNAME:PASSWORD@IP:PORT

but am having no success.

I've tried following the docs to no avail. I've also tried the -verbose-proxy setting but this no longer seems to exist.

Any pointers?

16 Answers

I remember having the same problem - After searching on the web, I found this solution - From the command line,

1. > adb shell
2. # sqlite3 /data/data/com.android.providers.settings/databases/settings.db
3. sqlite> INSERT INTO system VALUES(99,’http_proxy', 'proxy:port');
4. sqlite>.exit

EDIT: Edited answer to reflect the latest version of Android.

Jay, though that would be the ideal place for this information, it has not been updated for 2.1. Below I will list the methods that currently do NOT work for the 2.1 emulator.

The http-post argument does not work for the 2.1 emulator. Setting a proxy in the APN list within the 2.1 emulator does not work. Inserting the proxy directly into the system table via sql-lite does not work with 2.1.

In fact, the ONLY way to get the browser to connect to the internet via the emulator that I've found in 2.1, is to NOT use a proxy at all. I really hope this gets fixed soon, for there are many people with this same problem.

I've not used the Android Emulator but I have set the $http_proxy environment variable for perl and wget and a few cygwin tools on windows. That might work for you for android, but the slash in the domain name seems like a potential problem. I know I tried having my domain "GLOBAL" in there, but ended up taking it out and sticking with: http://$USER:password@www-proxy.company.com:80

One problem I run into a lot though is programs that cannot be told to use the proxy for DNS queries too. In cases where they don't I always get a host name not found. I'd like to find a local dns resolver that can use the proxy for all the programs that won't.

I was able to view the traffic with an HTTP sniffer instead of a proxy. I used HTTPScoop, which is a nice little app.

Also the nice thing about using HTTPScoop is that I can also see traffic on my actual device when I turn on internet sharing and have my phone use the wifi from my mac. So this is a good deal for debugging what happens on the phone itself AND the emulator.

This way it doesn't matter what emulator you use, because the sniffer sees the traffic independent of the emulator, device, compiler settings etc.

With the new versions of Android Studio and its emulator, it is an easy task.

Press the emulator's "More" button, and choose the Settings -> Proxy tab. All the needed configurations are there.

enter image description here

Related