可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
Has anybody managed to get the Android Emulator working behind a proxy which 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?
回答1:
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"
回答2:
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.
回答3:
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:
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:
Find the file androidtool.cfg
at C:\Documents and Settings\YOUR USER NAME\.android\
Add this line:
http.proxyLogin=USER@PASSWORD
Save the file and try to open the Android SDK.
回答6:
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
回答7:
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...
回答8:
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.
回答9:
Start command prompt.
Go the folder where your emulator is located. In general, it will be in the tools folder of the Android SDK.
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.
回答10:
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.
回答11:
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.
回答12:
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.
回答13:
I will explain all the steps:
- 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...
回答14:
For Android2.3.3
Settings->Wireless&Networks->MobileNetworks->AccessPointNames->Telkila->
set the Proxy and the Port here (xx.xx.xx.xx and port)
回答15:
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 :)
回答16:
With the new versions of Android Studio and it's emulator it is an easy task.
Press emulator's "More" button, choose Settings -> Proxy tab. All the needed configurations are there.