Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access host machine's network from android emulator

Is there a way to access my host machine's network?

Specifically I want to scan host machines network and find devices connected to same network.

like image 944
Martynas Jurkus Avatar asked Feb 11 '18 22:02

Martynas Jurkus


People also ask

How do I find the IP address of my Android emulator?

Just to clarify: from within your app, you can simply refer to the emulator as 'localhost' or 127.0. 0.1. Web traffic is routed through your development machine, so the emulator's external IP is whatever IP has been assigned to that machine by your provider.

Can emulator connect to Internet?

If your emulator must access the internet through a proxy server, you can configure a custom HTTP proxy from the emulator's Extended controls screen. With the emulator open, click More , and then click Settings and Proxy. From here, you can define your own HTTP proxy settings.


2 Answers

In short, you can't. The simulator can only talk to the host machine. the host must provide the service to access other resources on the network.

previous text:

The android simulator is not on your home or office network. As this was said before.. there is a small network bridge between the computer and the simulator, can you can access the host computer via the IP 10.0.2.2.

Now to access other machines on the network, or perform a scan, you basically have two choices. either the host give you access via a tunnel.

or you join the network by some other mean. I am not sure the simulator can open a wifi connection, the device would need to be stubbed. maybe if your computer is connected via LAN cable and your wifi device delegated to the android simulator its possible.

the other choice is to use a VPN, so then every machine connected to the VPN would be on the same network.

your best bet is probably to use a real phone connected to the network via wifi.

like image 88
Mathieu J. Avatar answered Oct 21 '22 07:10

Mathieu J.


You can access your host machine by the IP: 10.0.2.2

like image 24
regev avraham Avatar answered Oct 21 '22 08:10

regev avraham