1

I am trying to run an Android Emulator on my host machine which is a Mac OS and connect to it from my Vmware fusion guest machine which is a Linux.

I tried all network configurations and also tried to port forward to the 5555 port from the localhost itself thinking I will be able to connect to the host machine using the ip address and a port that is forwarded to the Android emulator port but I am either not using the right commands or that is not the actual way. I read a lot about remote adb debugging over tcp but none of those helped... It usually shows connection refused or does nt show anything at all and times out.

What am I missing? Can anyone help?

Thank you

EDIT 1 - adding steps I tried:

By all network configurations I meant that I have tried all possible network configuration options in Vmware network tab:

enter image description here

I kept switching between configurations and after they were updated and propogated to the linux guest machine, I tried connecting to (and pinging as well) the ip of the emulator. The emulator does show an internal ip of 10.0.2.16 which is an "emulated ip" I assume? Which I cant really reach. Although the image shows I'm currently using WI-FI configuration, most of the time I'm using MyNAT which is a custom NAT configuration.

enter image description here

I then tried to port forward from the mac host machine to the emulator ip and 5555 port. But still I could not reach it.

I'll add that currently the ip I get for my mac host machine (wifi - tcp) is this:

enter image description here

I'm positive this is doable I'm missing something.

EDIT 2 - SSH tunneling

I also tried variation of this command:

ssh -L 192.168.5.15:10000:localhost:5555 -N 127.0.0.1

add

ssh -L 192.168.5.15:10000:10.0.2.16:5555 -N 127.0.0.1

I tried this answer as well... But I keep getting the password request until it quits with access denied

5
  • Nobody knows what exactly you mean by "I tried all" as it differs greatly from person to person. To get a valid answer to your question it would help if you include the actual steps which you have taken in detail. Commented Dec 16, 2021 at 6:12
  • @mashuptwice Hi, Thanks for replying. I understand your reasoning but I do believe someone that knows the answer or is more experienced, would be able to deduce what "I tried all network configurations" means in regards to Vmware. It does not differ greatly from person to person as you say. Nevertheless, to gain more grounds. I'll update my question with step by step taken. Thanks. Commented Dec 16, 2021 at 8:55
  • Forwarding port 5555 should be the correct approach. Based on your description I am not sure if you are forwarding it from/to the correct machine. Port 5555 should be open on your MacOS system (running the emulator). Forward this port into the VMWare guest (e.g. via ssh port forwarding) should be enough in my understanding. Alternatively you could try adb connect command.
    – Robert
    Commented Dec 16, 2021 at 14:31
  • @Robert Hi, thanks for replying... I did try commands such as ssh -L 192.168.5.15:10000:localhost:5555 -N 127.0.0.1 as suggested in a few sites but I kept hitting a password: request. What ever I tried did not pass and eventually I got access denied. I'm assuming the password request is not for my MacOs host machine but rather for the emulator? Not sure. Anyway, trying variations on this theme did not succeed either :( Commented Dec 16, 2021 at 14:34
  • The ssh login request is from the machine that is the ssh target. But also your forwarding port is wrong. Adb only searches in the port range 5555 to 5585 for emulators. Also make sure the emulator really uses 5555 and not one of the other allowed ports developer.android.com/studio/command-line/adb#howadbworks
    – Robert
    Commented Dec 18, 2021 at 13:35

1 Answer 1

1

Ok, I finally got it to work. For anyone interested:

On host machine (Macos):

  1. adb kill-server
  2. cd /tmp
  3. mkfifo backpipe
  4. nc -kl 5555 0<backpipe | nc 127.0.0.1 5555 > backpipe

This command will forward any tcp packet received on 5555 to the local 5555 port and will forward back from local 5555 to the external 5555. Keep this terminal window open.

On guest machine (linux):

  1. adb connect mac-ip-address:5555
  2. adb devices should show the device as online.

If the devices is not authorized, make sure to accept the key request in the emulator as usual.

I can now debug on this emulator from my guest machine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .