How do I specify which network interface the Android emulator should use on my development machine?

三世轮回 提交于 2019-12-09 16:02:34

问题


My development machine is simultaneously connected to two different networks. One is through ethernet (eth0), and the other is WiFi (en1). In this situation, the Android emulator appears to always want to reach out to the network on eth0. When starting the emulator from the command line, is there an option where I can tell it to use a specific network interface on the development machine (en1 in my case)?

It seems like this should be possible through args you can pass to the -qemu flag. However, the current version of the emulator will not start when you use this flag.


回答1:


If you are only communicating with a specific address or subnet you can set up an apropriate route on the host machine by using the route add command. The syntax differs slightly for Windows and Linux:

Linux

route add -net target-ip netmask 255.255.255.0 metric 1 gw en1

Windows

route add target-ip mask 255.255.255.0 en1-gw-address metric 1 -p

You might want to adjust the netmask value (255.255.255.0) to your needs.




回答2:


IMHO this is not possible since the emulator uses a virtual router rather than a physical network interface of your development PC

Have a closer look at this link - there is some detailed information about that
http://developer.android.com/guide/developing/devices/emulator.html#emulatornetworking



来源:https://stackoverflow.com/questions/7231560/how-do-i-specify-which-network-interface-the-android-emulator-should-use-on-my-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!