Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 784
Eric Levine Avatar asked Aug 29 '11 14:08

Eric Levine


2 Answers

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.

like image 74
mattlaabs Avatar answered Sep 19 '22 16:09

mattlaabs


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

like image 41
DonGru Avatar answered Sep 21 '22 16:09

DonGru