Reputation: 1397
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:
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.
Upvotes: 80
Views: 89210
Reputation: 81
If anyone is still having the same problem, try using this command in your mac terminal.
~/Library/Android/sdk/emulator/emulator -avd <AVD_NAME> -dns-server 8.8.8.8
it basically changes your emulator dns settings as google's dns.
Upvotes: 0
Reputation: 2943
This thread is so old, however, it might be helpful to someone - I spent so much time trying to fix this same issue (On Android 13/14 Emulators), I tried cold boot, resetting the data, and all the options I could find in the SO or other places. Nothing worked for me.
Then I came across these 2 solutions below, both worked for me -
Option 1: This needs to be done everytime when we cold boot emulator I accidentally turned off the Android Wi-Fi inside the Emulator. After that, my emulator could connect through my Laptop's VPN.
Option 2: Issue was Android given IP Address of 10.0.x.x interfering with VPN IP range I changed the Android Wifi DHCP setting to not use Android Emulators IP and Gateway config, instead I just used my network Ip Address and Gateway static. That also worked. I think this works because now Android cannot route through its default range - just like turning off the AndroidWifi.
Upvotes: 1
Reputation: 372
The solution depends on your environment, for me: win10+V2ray(VPN client)+android studio.
The solution works:
I found this at the bottom of the V2ray.
I suppose the default port for HTTP is 1081, and socks is 1080, so I tried both. And here 1081 works.
If you use another VPN client, try to replace your port, and it may work.
Upvotes: 2
Reputation: 1919
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.
Upvotes: 23
Reputation: 5351
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.
Upvotes: 3
Reputation: 1071
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.
Upvotes: 107
Reputation: 77
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
Upvotes: 6
Reputation: 6150
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.
Upvotes: 10