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

AndroidAndroid EmulatorVpnNetwork Connection

Android Problem Overview


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.

Android Solutions


Solution 1 - Android

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.

Solution 2 - Android

enter image description here

I encountered this issue and tried something on dns settings but I could not solve it. As @machado said in the comment section below you should boot the emulator via "Cold Boot Now" option. I hope this helps.

Solution 3 - Android

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

Solution 4 - Android

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

Solution 5 - Android

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionumassthrowerView Question on Stackoverflow
Solution 1 - AndroidCiro HuangView Answer on Stackoverflow
Solution 2 - Androidseyfullah.bilginView Answer on Stackoverflow
Solution 3 - AndroidAndrewPKView Answer on Stackoverflow
Solution 4 - AndroidLuchezcoView Answer on Stackoverflow
Solution 5 - AndroidAftershockView Answer on Stackoverflow