Home » Android » How can I get my android emulator use my computer's VPN interface?

How can I get my android emulator use my computer's VPN interface?

Posted by: admin April 23, 2020 Leave a comment

Questions:

My company requires VPN to connect to our dev systems and for the first time I’m trying to work on an android app from home. Turns out the emulator doesn’t want to use the VPN interface so even though I have connectivity to our dev systems on my VPN-connected laptop the emulator that’s running on it does not.

I have thought of 3 solutions to this:

  1. run a VPN client on the emulator, but I was hoping for a simpler solution than that
  2. setting up a proxy server on my local machine
  3. forwarding a port on my local machine

2 and 3 can probably work, but I’d still like to know if there is an easy way to get the emulator to use the VPN interface without a workaround.

I’m running OS X 10.7 and I’ve already tried adjusting the interface priority order with network>>set service order.

I suppose I can dust off the old dell and try it there, but I would expect the same results.

How to&Answers:

First start your vpn connection and then restart the emulator, now the emulator should use the host vpn connection.

it’s mostly because of the DNS issue, according to the android doc:

At startup, the emulator reads the list of DNS servers that your system is currently using. It then stores the IP addresses of up to four servers on this list and sets up aliases to them on the emulated addresses 10.0.2.3, 10.0.2.4, 10.0.2.5 and 10.0.2.6 as needed.

Answer:

What I do on my mac is just make sure ‘send all traffic over vpn’ is checked.
You’ll find this setting after you click advanced while having your vpn connection selected in network preferences.

Works well for my situation, but may not depending on the type of VPN you’re connecting to.

VPN Advanced Settings

Answer:

I had the same issue and solved it by connecting to cisco vpn after the android emulator has started and connected to the internet.

Works for me in windows 7

Answer:

I setup a vpn connection on Windows. Then I started the emulator. The emulator and everything on my pc started to use that vpn connection.

Answer:

These solutions were not working for me.

I found that you can override the 3G Mobile network connection DNS server using this app on the Android emulator or real devices.

Link to play store