56

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?

2

16 Answers 16

46

I Managed to do it in the Adndroid 2.2 Emulator.

Go to "Settings" -> "Wireless & Networks" -> "Mobile Networks" -> "Access Point Names" -> "Telkila"

Over there set the proxy host name in the property "Proxy" and the Proxy port in the property "Port"

5
  • if entering your username, remember to include domain name [ domain\username] otherwise you get the proxy auth popup.
    – scottyab
    Dec 24, 2010 at 11:45
  • 24
    These proxy settings work for the browser in Android - but not for the app. Did anyone faced a similar issue? Sep 7, 2011 at 15:51
  • @AbhimanyuGrover yes I've the same problem, have you already solved it?
    – aF.
    Dec 22, 2011 at 10:50
  • 1
    is there any way that we programatically put the proxy setting to use in our app?
    – Ege Özcan
    Mar 26, 2012 at 12:08
  • Actual IP address only works, not the name of the proxy server. Dec 17, 2013 at 4:46
26

It seems like SDK 1.5 onwards, the -http-proxy flag also doesn't work. What did work for me is to boot the android image in the emulator and then once Android is running, go to Home > Menu > Settings > Wireless Controls > Mobile Networks > Access Point Names and then setup the http proxy settings for the default access point.

With the APN proxy settings in place, I can get the emulator's browser to surf the web. However, other stuff like Maps still doesn't work.

15

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.

4
  • 2
    in sdk 2.1, it should be: sqlite3 /data/data/com.android.providers.settings/databases/settings.db
    – Lily
    Aug 18, 2010 at 19:52
  • I am doing with 2.3, it is showing the error: Error: unable to open database "/data/data/com.google.android.providers.settings/databases/settings.db": unable to open database file May 4, 2011 at 5:28
  • 1
    Error is resolved: In 2.3, it should be sqlite3 /data/data/com.android.providers.settings/databases/settings.db as Lily has stated above. May 4, 2011 at 5:30
  • I have error: "No such table: system". When I go to sqlite3 and this location and type ".tables" I have empty database. When I type ".databases" I can see "main". I use Android Emulator, nexus4, api23. Please help.
    – liquide
    Oct 20, 2015 at 14:26
5

Apparently this problems runs only with Android 2.x and Windows. There is a opened bug here : http://code.google.com/p/android/issues/detail?id=5508&q=emulator%20proxy&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

5
  1. Find the file androidtool.cfg at C:\Documents and Settings\YOUR USER NAME\.android\

  2. Add this line:

    http.proxyLogin=USER@PASSWORD
    
  3. Save the file and try to open the Android SDK.

2
  • 1
    i m getting 407 Proxy Auth error... still it is not working... :( Jul 12, 2012 at 14:10
  • 407 means your Proxy needs authentification with username and password
    – Radon8472
    Aug 10, 2016 at 21:00
5

For setting proxy server we need to set APNS setting. To do this:

  • Go to Setting
  • Go to wireless and networks
  • Go to mobile networks
  • Go to access point names. Use menu to add new apns
  • Set Proxy = localhost
  • Set Port = port that you are using to make proxy server, in my case it is 8989

For setting Name and apn here is the link:

According to your sim card you can see the table

4

This worked for me: http://code.google.com/p/android/issues/detail?id=5508#c39
Apparently there's a bug in the emulator that forces you to use the IP address of the proxy instead of the name...

3

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.

3
  1. Start command prompt.

  2. Go the folder where your emulator is located. In general, it will be in the tools folder of the Android SDK.

  3. Then use the following command:

    emulator -avd <avd name> -http-proxy <server>:<proxy>
    

    By using this, we will be able to access the internet using the browser.

3

Using Android SDK 1.5 emulator with proxy in Eclipse 3.45

Go to Package Explorer -> Right click your Android project ->Run As->Run Configurations.

Under Android Application on the left column, select your project -> on the right column, where you see Android | Target | Common tabs ->

Select Target -> on the bottom “Additional Emulator Command Line Options”->

-http-proxy http://www.gateProxy.com:1080 -debug-proxy http://www.gateProxy.com:1080

->Run/Close.

0
2

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:[email protected]: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.

2

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.

2

I will explain all the steps:

  1. Go to settings in Android emulator > Wireless & Network > Mobile network > Access point > Telkilla > and here do necessary settings such as proxy, port, etc.

I think now everything is clear about proxy settings...

0
2

For Android2.3.3 Settings->Wireless&Networks->MobileNetworks->AccessPointNames->Telkila-> set the Proxy and the Port here (xx.xx.xx.xx and port)

0
1

I had the same problem when i use the following command:

emulator-x86.exe -http-proxy domain\user:password@proxyIP:port -avd MyAVD

I got the proxy authentication error.

Finally, I had to bypass the proxy NTLM authentication by using the Cntlm here:

http://sourceforge.net/projects/cntlm/

And then after simply configuring the cntlm.ini, I use the following command instead:

emulator-x86.exe -http-proxy 127.0.0.1:3128 -avd MyAVD

and it works :)

1
1

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

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.