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.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You access your computer's
localhost
as10.0.2.2
from emulator. more details hereTo 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:
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: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: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:
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...
You can use the adb forward command to set up arbitrary port forwarding — forwarding of requests on a specific host port to a different port on an emulator/device instance. Here's how you would set up forwarding of host port 6100 to emulator/device port 7100:
For example run NanoHTTPD web server on the AVD and then execute this command on the computer:
Open the browser on the computer and navigate the below address:
http://developer.android.com/tools/help/adb.html#forwardports