4

What is the IP address of android emulator, by what I found SEVERAL information on the internet, 127.0.0.1, 10.0.0.2 or 10.0.015 to call the emulator from web server (apache). is that the port of the emulator is fixed?

user2282259
  • 155
  • 1
  • 3
  • 9

5 Answers5

8
  • 10.0.2.1 - Router/gateway address
  • 10.0.2.2 - Special alias to your host loopback interface (i.e., 127.0.0.1 on your development machine)
  • 10.0.2.3 - First DNS server
  • 10.0.2.4 / 10.0.2.5 / 10.0.2.6 - Optional second, third and fourth DNS server (if any)
  • 10.0.2.15 - The emulated device's own network/ethernet interface
  • 127.0.0.1 - The emulated device's own loopback interface

http://developer.android.com/tools/devices/emulator.html

Nofate
  • 2,714
  • 3
  • 32
  • 32
  • thanks @piyush-machhoya, the url to ip address is https://developer.android.com/studio/run/emulator-networking.html – Bakhshi May 04 '17 at 00:55
5

Use this method you will be getting 100% correct ip address for your android emulator

To get the ip address of yoor emulator

Go to adb shell and type this command

adb shell
ifconfig eth0

enter image description here

After running this command I am getting

IP : 10.0.2.15

Mask : 255.255.255.0

Which works for me . I am also working for an networking application.

Nikhil Agrawal
  • 26,128
  • 21
  • 90
  • 126
  • 2
    If `ifconfig eth0` doesn't work, just try `ifconfig` and you'll likely find it under "wlan0". – OJ7 Sep 05 '19 at 15:27
0

Android emulator's external IP address is 10.0.2.2.

Source: link.

kamituel
  • 34,606
  • 6
  • 81
  • 98
  • 7
    Folks, please stop upvoting this. Heven't you ever started several AVDs at the same time? From that alone it must be clear that this answer must obviously be insufficient. Or have you ever had an IP address conflict when you started several AVDs? I haven't. – class stacker Apr 16 '13 at 10:06
  • 10.0.2.2 is the IP address of the machine running the emulator as @Piyush Machhoya mentions. It is not the emulated devices IP. – Doug Aug 11 '17 at 00:52
0

Use adb shell from command line to log-in in your device and run netcfg to see its network configuration. Now you are also future-proof. Don't give a man a fish.. Teach him how to fish :D

baske
  • 1,316
  • 9
  • 16
-1

Try to look for "HttpHost" class. http://developer.android.com/reference/org/apache/http/HttpHost.html