[英]Android emulator does not have eth0 when checked using adb shell ifconfig
I am following a set of instruction of how to check emulator ip (should be 10.0.2.15). 我正在遵循一组有关如何检查仿真器ip的指令(应为10.0.2.15)。
The instruction is simple 指令很简单
adb shell ifconfig eth0 亚行外壳ifconfig eth0
However I get bellow error. 但是我得到波纹管错误。
ifconfig: eth0: No such device ifconfig:eth0:没有这样的设备
doing ifconfig -a give bellow devices 做ifconfig -a给波纹管设备
generic_x86:/ $ ifconfig
radio0 Link encap:UNSPEC
inet addr:192.168.200.2 Bcast:192.168.200.255 Mask:255.255.255.0
inet6 addr: fec0::c85f:8d1e:6e52:3f14/64 Scope: Site
inet6 addr: fec0::7854:d4ff:fe56:b633/64 Scope: Site
inet6 addr: fe80::7854:d4ff:fe56:b633/64 Scope: Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:725 errors:0 dropped:0 overruns:0 frame:0
TX packets:728 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:97723 TX bytes:73200
wlan0 Link encap:UNSPEC Driver mac80211_hwsim
inet addr:192.168.232.2 Bcast:192.168.239.255 Mask:255.255.248.0
inet6 addr: fe80::ff:fe44:5566/64 Scope: Link
inet6 addr: fec0::bcd4:4637:9032:f4cc/64 Scope: Site
inet6 addr: fec0::ff:fe44:5566/64 Scope: Site
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:96591 errors:0 dropped:0 overruns:0 frame:0
TX packets:40225 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:132047321 TX bytes:3916668
lo Link encap:UNSPEC
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope: Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1075 errors:0 dropped:0 overruns:0 frame:0
TX packets:1075 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:76576 TX bytes:76576
Is any of them etho (hence having 10.0.2.15 ip address? I don't think so!) or eth0 is not there and how to add it, enable it or troubleshoot this issue? 它们中是否有人(因此具有10.0.2.15的IP地址?我不这样认为!)或eth0不存在,以及如何添加它,启用它或解决此问题?
Thanks in Advance! 提前致谢!
You are using a higher version of android API (>= 25). 您正在使用更高版本的android API(> = 25)。 I think eth0 is in namespace router of your emulator. 我认为eth0在模拟器的名称空间路由器中。 API <= 24 are using eth0 to simulate cellular network, so you could find it by typing ifconfig
directly. API <= 24正在使用eth0模拟蜂窝网络,因此您可以通过直接键入ifconfig
来找到它。 API >= 25's eth0 is in namespace router
, you could find it by typing execns router ifconfig
API> = 25的eth0在命名空间router
,您可以通过键入execns router ifconfig
来找到它
Just after asking this question I found a solution. 在问了这个问题之后,我找到了解决方案。 It is a workaround and does not really answer this question. 这是一种解决方法,并不能真正回答这个问题。 But might help others that are stuck with similar problem. 但是可能会帮助其他陷入类似问题的人。
Rather than accessing that 10.0.2.15 ip (that is missing because no eth0). 而不是访问该10.0.2.15 ip(因为没有eth0,所以缺少了它)。 We can forward android emulator port to the development machine ip (which is local ip or localhost or 127.0.0.1). 我们可以将android仿真器端口转发到开发机ip(本地ip或localhost或127.0.0.1)。
Execute bellow command in the development machine cmd prompt or console (and not inside adb shell). 在开发机cmd提示符或控制台中(而不是在adb shell中)执行bellow命令。
adb forward tcp: tcp: adb转发tcp:tcp:
or in my case I successfully visit localhost:20202 by doing bellow command 或者我通过执行以下命令成功访问了localhost:20202
adb forward tcp:20202 tcp:8080 亚行转发tcp:20202 tcp:8080
For those who are wondering why I have http server running in my Android emulator. 对于那些想知道为什么我的Android模拟器中运行http服务器的人。 It is because I am playing around with NanoHttpd 这是因为我在玩NanoHttpd
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.