本文介绍了如何指定Android模拟器在开发计算机上应使用哪个网络接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发机器同时连接到两个不同的网络.一种是通过以太网(eth0),另一种是WiFi(en1).在这种情况下,Android模拟器似乎总是想与eth0上的网络联系.从命令行启动仿真器时,是否可以选择让我告诉它使用开发计算机上的特定网络接口(在我的情况下为en1)?

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)?

似乎可以通过args来实现,您可以将其传递给 -qemu标志.但是,当您使用此标志时,当前版本的仿真器将无法启动.

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.

推荐答案

如果仅与特定地址或子网通信,则可以使用 route add 命令. Windows和Linux的语法略有不同:

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 网络掩码255.255.255.0 metric 1 gw en1

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

Windows

路由添加 target-ip 掩码255.255.255.0 en1-gw-address 指标1 -p

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

您可能需要根据需要调整网络掩码值(255.255.255.0).

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

这篇关于如何指定Android模拟器在开发计算机上应使用哪个网络接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 15:27