Need help with Android Emulator Networking

Here is the cmd line

"C:\Progra~2\Android\android-sdk\tools\emulator.exe" -avd Touch -netspeed full -netdelay none -http-proxy localhost:3128 -debug-proxy 

here is the console when i try to open google.com from emulator:

 server name 'localhost' resolved to 127.0.0.1:3128 proxy_http_setup: creating http proxy service connecting to: localhost:3128 server name 'localhost' resolved to 127.0.0.1:3128 proxy_http_setup: creating HTTP Proxy Service Footer is (len=2): ' ' http_service_connect: trying to connect to (null) http_service_connect: using HTTP rewriter tcp:(null)(880): connecting tcp:(null)(880): connected to http proxy, sending header tcp:(null)(880): sending 27 bytes: >> 43 4f 4e 4e 45 43 54 20 28 6e 75 6c 6c 29 20 48 CONNECT (null) H >> 54 54 50 2f 31 2e 31 0d 0a 0d 0a TTP/1.1.... tcp:(null)(880): header sent, receiving first answer line tcp:(null)(880): received 'HTTP/1.0 400 Bad Request' tcp:(null)(880): connection refused, error=400 http_service_connect: trying to connect to (null) http_service_connect: using HTTP rewriter tcp:(null)(888): connecting 

Here is the exception to the Wikadary debug example

 Caused by: java.net.ConnectException: en.wiktionary.org/91.198.174.232:80 - Connection refused 

About my proxy: this is a squid on my local machine, and it is configured to route through the parent proxy (using auth). This works fine with the browser loader / Android SDK / IntelliJ, etc., but network emulation does not work.

The main confusion is

 tcp:(null) 

Any suggestions?

+6
source share
3 answers

There are many problems with proxy server support in the emulator, especially for the latest versions of Windows. See Error Report here:

http://code.google.com/p/android/issues/detail?id=5508&q=emulator%20proxy&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

There are some suggested workarounds that can help, for example, install a proxy server in network settings, and not for the emulator as a whole.

+2
source

I have the same problem (Mac OS X - Android SDK Tools 12). These are my logs from logcat:

08-04 15: 33: 41.576: INFO / java.net.Socket (256): www.google.com/209.85.148.104(80): java.net.ConnectException: www.google.com/209.85. 148.104: 80 - Connection rejected

I use squid as a proxy, and the logs are:

1312464815.525 0 172.16.1.1 TCP_DENIED / 400 1587 CONNECT: 0 - NONE / - text / html

Something seems to be missing ...

I also noticed that the emulator is trying to use my DNS in the query.

+1
source

Since you are referencing localhost on your system from an Android emulator, you should use http://10.0.2.2:8080/ . This is due to the fact that the android emulator works inside the virtual machine, and therefore here 127.0.0.1 or localhost will be the emulator's own loopback address. In addition, you do not need to set -netspeed full -netdelay none , since these properties are set by default by default. See this one for more information on the network of emulators.

EDIT:

You are replacing localhost with a different address depending on your situation. If this is the address of the router / gateway, replace it with 10.0.2.1 . If this is a special alias of your loopbackback interface (i.e. 127.0.0.1 on your development machine), you replace it with 10.0.2.2 . If this is the first DNS server, replace it with 10.0.2.3 . If this is an additional second, third, and fourth DNS server, you replace it with 10.0.2.4 / 10.0.2.5 / 10.0.2.6 . If this is your own / ethernet network interface with an emulated device, you replace it with 10.0.2.15 . If this is the native loopback interface of the emulated device, you replace it with 127.0.0.1 . In addition, the address 127.0.0.1 on your development computer corresponds to the emulator’s own loopback interface, so if you want to access the services running on your development loopback interface, you must use the special address 10.0.2.2 . Click here for more information on this.

0
source

Source: https://habr.com/ru/post/893265/


All Articles