How to enable VPN support in Android Emulator

17,230

Solution 1

yes it is like kernal issue:

  1. No tun.ko module (see http://forum.xda-developers.com/showthread.php?t=630703&page=2)
  2. No support lkm (loadable kernel module) (http://code.google.com/p/get-a-robot-vpnc/issues/detail?id=100)

So I think you need custom kernel http://code.google.com/p/batterymine/wiki/BuildingInModuleSupport

Also you will need copy to emulator other modules: slhc.ko, ppp*.ko

Solution 2

I had the same problem with a 2.2 emulator. I switched to a 4.2 emulator and it is working fine through the VPN.

Share:
17,230

Related videos on Youtube

Sebastian Roth
Author by

Sebastian Roth

Welcome to my page. I'm a Solutions Engineer working for Snyk. Some projects I've been working on in the past months: Various iPhone & Android Projects at Nextbase, with a total install base of about 600k users. Get in touch for a comprehensive portfolio. Get in touch: Xing, Twitter, My Website

Updated on June 04, 2022

Comments

  • Sebastian Roth
    Sebastian Roth almost 2 years

    I like to use a PPTP VPN in the Android emulator. My VPN provider is Witopia. The settings work on a real phone (HTC Desire).

    It does not work, the connection just times out after a while.

    adb logcat prints:

    D/VpnManager( 1527): succeeded to connect to VPN service
    D/com.android.settings.vpn.AuthenticationActor( 1527): ~~~~~~ connect() succeeded!
    I/SProxy_mtpd( 2211): Stop VPN daemon: mtpd
    D/VpnSettings( 1527): received connectivity: Witopia: connected? CONNECTING   err=0
    D/SProxy_mtpd( 2211): mtpd is stopped after 0 msec
    D/SProxy_mtpd( 2211): stopping mtpd, success? true
    I/SProxy_racoon( 2211): Stop VPN daemon: racoon
    D/SProxy_racoon( 2211): racoon is stopped after 0 msec
    D/SProxy_racoon( 2211): stopping racoon, success? true
    D/VpnService( 2211):   Local IP: 10.0.2.15, if: eth0
    D/VpnService( 2211):        VPN UP: down
    I/SProxy_mtpd( 2211): Start VPN daemon: mtpd
    D/SProxy_mtpd( 2211): mtpd is running after 0 msec
    D/SProxy_mtpd( 2211): service not yet listen()ing; try again
    D/mtpd    ( 2224): Waiting for control socket
    D/mtpd    ( 2224): Received 19 arguments
    I/mtpd    ( 2224): Using protocol pptp
    I/mtpd    ( 2224): Connecting to 203.131.247.213 port 1723
    I/SProxy_mtpd( 2211): got data from control socket: 19
    I/mtpd    ( 2224): Connection established (socket = 10)
    D/mtpd    ( 2224): Sending SCCRQ
    D/mtpd    ( 2224): Received SCCRP -> Sending OCRQ (local = 32087)
    I/mtpd    ( 2224): Tunnel established
    D/mtpd    ( 2224): Received OCRQ (remote = 52286)
    I/mtpd    ( 2224): Session established
    I/mtpd    ( 2224): Creating PPPoX socket
    F/mtpd    ( 2224): Socket() Address family not supported by protocol
    

    Followed by the user message: Unable to connect to the network. Do you want to try again?

    Meanwhile in adb logcat

    E/VpnService( 2211): onError()
    E/VpnService( 2211): java.io.IOException: Connecting timed out
    E/VpnService( 2211):    at com.android.server.vpn.VpnService.waitUntilConnectedOrTimedout(VpnService.java:206)
    E/VpnService( 2211):    at com.android.server.vpn.VpnService.onConnect(VpnService.java:136)
    E/VpnService( 2211):    at com.android.server.vpn.VpnServiceBinder$2.run(VpnServiceBinder.java:114)
    E/VpnService( 2211):    at java.lang.Thread.run(Thread.java:1096)
    I/VpnService( 2211): disconnecting VPN...
    D/VpnSettings( 1527): received connectivity: Witopia: connected? DISCONNECTING   err=0
    I/SProxy_mtpd( 2211): Stop VPN daemon: mtpd
    D/SProxy_mtpd( 2211): mtpd is stopped after 0 msec
    D/SProxy_mtpd( 2211): stopping mtpd, success? true
    I/SProxy_racoon( 2211): Stop VPN daemon: racoon
    D/SProxy_racoon( 2211): racoon is stopped after 0 msec
    D/SProxy_racoon( 2211): stopping racoon, success? true
    D/VpnService( 2211): onFinalCleanUp()
    I/VpnService( 2211): restore original suffices --> null
    D/VpnSettings( 1527): received connectivity: Witopia: connected? IDLE   err=101
    

    I guess this is either a permission problem or the Android emulator does not support it.

    My platform is MacOSX, Emulator is running Android 2.2.

    This question is related to:

    • Sebastian Roth
      Sebastian Roth over 13 years
      I bought another device (a iRobot tablet) and tried the VPN there. Same message regarding Address family not supported by protocol. So this might be a kernel issue?
    • garima
      garima over 13 years
      check these lines...com.android.server.vpn.VpnService.onConnect(VpnServi‌​ce.java:136) E/VpnService( 2211): at com.android.server.vpn.VpnServiceBinder$2.run(VpnServiceBind‌​er.java:114)
  • Sebastian Roth
    Sebastian Roth over 13 years
    I think that's it, didn't know it's possible to install custom kernels in the emulator! Thanks a lot, sibnick!
  • blackfyre
    blackfyre over 11 years
    @Sebastian Roth: Can you please tell me exactly which kernal is required by emulator? I checked this link ttp://forum.xda-developers.com/showthread.php?t=630703&page=‌​2, but its procedure is for Nexsus one, will it be the same for emulator, where can I get tun.ko,slhc.ko, ppp*.ko for emulator (API level 15). Do I need some other modules too?!