How can I forward my localhost IP-Address to an Android Emulator?(如何将我的本地主机 IP 地址转发到 Android 模拟器?)
问题描述
我知道可以将端口从我的开发机器转发到 Android 模拟器,但这是如何完成的?我在 android-developers 网站上找到了解决方案,但我看不出他们的意思是什么......有人对此有明确的指示吗?我的开发机器正在运行 Windows.
I know it is possible to forward a port from my develop machine to an Android emulator, but how is this done? I've found the solution on the android-developers site, but I couldn't see how they've meant their instructions... Anybody got some clear instructions on this? My develop machine is running Windows.
推荐答案
要将端口从本地计算机转发到 Android 模拟器,您需要启用 Telnet.这是通过控制面板 -> 程序和功能 -> 打开或关闭 Windows 功能 -> 向下滚动到 Telnet 客户端来完成的.然后选择它 &按确定.现在从命令提示符(运行模拟器)输入telnet localhost "EmulatorPortNumber"
.EmulatorPortNumber"可以在模拟器的标题栏中找到,在我的例子中是 5554.
To forward a port from your local machine to an Android Emulator, you need to have Telnet enabled. This is done through the Control Panel -> Programs and Features -> Turn Windows features on or off -> scroll down to Telnet Client. Then select it & press Ok. Now from your command prompt (with the Emulator running) you type telnet localhost "EmulatorPortNumber"
. The "EmulatorPortNumber" can be found in the titlebar of the Emulator, in my case it was 5554.
你现在会看到类似这样的东西:
You will now see something similar to this:
Android Console: type 'help' for a list of commands
OK
在这里,您希望输入尽可能少的拼写错误,因为当您应用退格键时,它会破坏您的命令并且不接受它.您必须在此处使用的命令是 redir
.这将让您从 3 个子命令中进行选择:
Here, you want to type with as little as possible typo's, as when you apply the backspace, it will corrupt your command and not accept it. The command you have to use here is redir
. This will let you choose from 3 subcommands:
list list current directions
add add new redirection
del remove existing redirection
您现在需要的是添加.但是你不能就这样使用它.键入 redir add
将显示以下行:
The one you need now is add. But you can't use it just like that. Typing redir add
will give you the following line:
KO: bad redirection format, try (tcp|udp):hostport:guestport
这意味着你必须指定你要转发什么样的端口(TCP或UDP端口),你要转发本地机器上的哪个端口(hostport)&你想在模拟器上设置哪个端口(guestport).所以,使用这样的命令:
This means that you have to specify what kind of port you want to forward (TCP or UDP port), which port on the local machine you want to forward (hostport) & which port you want to set on the Emulator (guestport). So, using a command like this:
redir add udp:1337:12345
将本地机器上的 UDP 端口 1337 转发到模拟器上的端口 12345.请谨慎删除重定向,因为它们可能会使您的模拟器崩溃.您也可以简单地关闭模拟器以删除任何重定向.它更容易&更安全...
forwards the UDP port 1337 on the local machine to port 12345 on the Emulator. Be cautious about deleting redirections, as they might crash your Emulator. You can also simply close the Emulator to remove any redirections. It's easier & safer...
这篇关于如何将我的本地主机 IP 地址转发到 Android 模拟器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将我的本地主机 IP 地址转发到 Android 模拟器?
基础教程推荐
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01