問題描述
我知道可以將端口從我的開發機器轉發到 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 模擬器?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!