How to enable VPN support in Android Emulator - android

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:
https://stackoverflow.com/questions/3223344/does-vpn-in-the-android-emulator-2-2-work
https://stackoverflow.com/questions/3442865/setting-up-a-vpn-in-the-emulator
will android emulator access a network using a vpn on the host machine

yes it is like kernal issue:
No tun.ko module (see http://forum.xda-developers.com/showthread.php?t=630703&page=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

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.

Related

Failed to debug Android app with physical device

After testing my Android app with Android studio on several devices with no problem, since a few days I get the following log in the console:
14:48 Unable to open connection to ADB server: java.io.IOException:
Can't find adb server on port 5037, IPv4 attempt: Connection refused:
connect, IPv6 attempt: Connection refused: connect
14:48 Failed to start monitoring 19134523021744
14:49 * daemon not running; starting now at tcp:5037
14:49 * daemon started successfully
14:49 * Failed to start monitoring 19134523021744
and it continues like this... starting the deamon thread and immediately after that it reports the errors above. In ther device list of Android Studio my physical devices continue to appear and disappear from the list.
It looks like the ADB is working intermittently and I'm not able to debug anymore. When I try to launch the app I get an error saying that "the device is offline", no matter which physical device I use. It works only with the emulator. I tried to restart the PC several times, checked the settings, to no avail. Any hint ?

An unknown server-side error occurred while processing the command. Could not proxy command to remote server. Original error: Error: socket hang up

If I ran TestNG test class it displays error ------------
org.openqa.selenium.WebDriverException: An unknown server-side error occurred while processing the command.
Original error: Could not proxy command to remote server. Original error: Error: socket hang up (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 281 milliseconds
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'MON-PC305', ip: '10.101.0.119', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities [{appPackage=com.app.android.game.app, statBarHeight=84, noReset=false, viewportRect={top=84, left=0, width=1440, height=2308}, deviceName=emulator-5554, platform=LINUX, deviceUDID=emulator-5554, desired={app="app path", appPackage=com.app.android.game.app, appActivity=com.app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity, noReset=false, automationName=uiautomator2, skipUnlock=true, platformName=Android, deviceName=emulator-5554}, platformVersion=9, webStorageEnabled=false, automationName=uiautomator2, takesScreenshot=true, skipUnlock=true, javascriptEnabled=true, platformName=Android, deviceApiLevel=28, deviceManufacturer=Google, app=C:\Users\***\eclipse-workspace\appname\app.apk, deviceScreenSize=1440x2560, networkConnectionEnabled=true, warnings={}, databaseEnabled=false, appActivity=com.app.android.game.app.activities.login.riskWarningLogin.RiskWarningLoginActivity, pixelRatio=3.5, locationContextEnabled=false, deviceScreenDensity=560, deviceModel=Android SDK built for x86}]
Session ID: d275d496-08b0-4652-9aa9-67ae0476cdc8
Stop appium server and execute below commands
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
start appium server and execute your scripts ..it will work
I ran into an exact error but the resolution was I had to just restart both my Android emulator and also Appium server. After that everything started working.
Stop appium server and execute below commands
adb uninstall io.appium.uiautomator2.server adb uninstall io.appium.uiautomator2.server.test
This happens because you have opened 2 driver instances in your code.
URL url = new URL(Common.getProperty("URL"));
driver = new AndroidDriver<WebElement>(url, capabilities);
The above stuff. Make sure you have initialized it once only in your suit otherwise it will through the same error you faced.
I ran into exact same issue. Below are the quick solutions without uninstalling anything:
If you are using real device (Android). Remove the usb cable and
switch off or restart your Android device.
If you are using emulator (Android). Shut it down and restart
accordingly.
Connect your real device/emulator and run your test everything should be working accordingly
No sure if it is the same, but I meet similar problem on the vivo phone when I run appium automation via the uiautomator2. The appium error log is like
[debug] [W3C (9ae907c5)] Encountered internal error running command: UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not proxy command to remote server. Original error: Error: socket hang up
[debug] [W3C (9ae907c5)] at JWProxy.command (/usr/local/lib/node_modules/appium/node_modules/appium-base-driver/lib/jsonwp-proxy/proxy.js:261:13)
[HTTP] <-- POST /wd/hub/session/9ae907c5-5319-4f0b-92dc-fdaa47cfdcc5/element 500 139 ms - 530
The reason on my side of this issue is io.appium.uiautomator2.server be killed by the system process com.vivo.abe, cause I catch the following log from the logcat
02-29 09:43:32.236 1742 15589 I ActivityManager: Force stopping io.appium.uiautomator2.server appid=10271 user=0: stop by com.vivo.abe
02-29 09:43:32.236 701 701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0
02-29 09:43:32.237 1742 15589 I ActivityManager: Killing 28683:io.appium.uiautomator2.server/u0a271 (adj 0): stop by com.vivo.abe
02-29 09:43:32.239 701 701 E ANDR-IOP: IOP HAL: Received pkg_name = io.appium.uiautomator2.server pid = 0
The com.vivo.abe (name as Vivo Wisdom engine) is system app on vivo phone, which could not be uninstalled or force stop. There is one solution to resolve this issue, just add io.appium.uiautomator2.server to the white list, then the com.vivo.abe will not perform kill again to the app.
Method is Setting -> Battery -> High background power consumption , then add the io.appium.uiautomator2.server to the allow list.
After I perform the action, the io.appium.uiautomator2.server will not be killed again, and the automation script could run smoothly.
Hope this can give some reference to resolve the problem.
The following worked for me, I was using virtual device in android studio
Open Android Studio Click on Configure.
Click AVD Manager.
Click on the Dropdown on the right hand side of the virtual device.
Click on Cold Boot Now.
You're done! The device will restart within a couple of minutes.
reference:https://stackoverflow.com/a/68688915/20916414
I also faced the similar issue. When you run into such issue, you just need to run the following command on your terminal:
adb uninstall io.appium.uiautomator2.server.test
You'll get a terminal success response. Re-run your Appium server and it will work fine.
I found a workaround in the meantime: (I'm using javascript with webdriver.io, but you can adjust to other client languages, it's the same basically)
1.- Add the Full reset in Android Capabilities 'appium:fullReset': true,
2.- In afterEach Method delete the session await driver.deleteSession();
afterEach(async function () {
await driver.deleteSession();
},2);
3.- Add 2 retries when you init the driver, in my case is the beforeEach method
beforeEach(async function () {
driver = await getAppiumClient();
}, 2);
Then it will fail the first or second times with socket hang up error, but i'll be running the third and subsequent tests successfully.

Android Emulator No Internet when using tethered iPhone

I've been struggling with this for a couple of days.
My Android Emulator does not have access to the Internet on Mac OS X when I use my iPhone's tethered Internet connection. I often use this connection whenever working on the go, so it's quite frustrating when it doesn't work.
I've tried the following:
Setting DNS and running emulator from command line.
./emulator -avd Pixel_2_API_26 -dns-server 8.8.8.8
Removing network connections except the tethered connection from Mac OS Networking.
Deleting and reinstalling the AVD.
Looking at the logs, the only networking related errors I get are:
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_FALLBACK http://www.google.com/gen_204 Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
I/qemu-props: start adbd ...
and
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_DNS www.google.com 78245ms FAIL
D/NetworkMonitor/NetworkAgentInfo [WIFI () - 101]: PROBE_HTTPS https://www.google.com/generate_204 Probably not a portal: exception java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
D/ConnectivityService: NetworkAgentInfo [WIFI () - 101] validation failed
D/WifiStateMachine: NETWORK_STATUS_UNWANTED_VALIDATION_FAILED
I feel like the simulator is still trying to use WiFi even though the WiFi device has been removed.

explanation for more than one jdwp port for android process

I am trying to debug android application using Jdb and other debuggers which use socket type of connector to connect to debuggee process. I know that we can forward jdwp port of process to local tcp port using adb jdwp and adb forward tcp:xxx jdwp:yyyy command and attach debugger. But during testing I have realised some processes return more than one jdwp port. So my question is what do those additional jdwp ports corresponds to or why is there more than one jdwp port for a single process ? And how to debug these kind of applications ?

Android emulator connecting to Laravel App on WAMP Server, issue: .failed to connect to /10.0.2.2 (port 8000) after 10000ms

Server - WAMP
Host - localhost/127.0.0.1/10.0.2.2(emulators ip address for hosts local server)
App - android(frontend), laravel(backend)
IDE - Android Studio
Ive tried multiple things to resolve this issue, from turning off my firewall to creating a virtual host with both a named virtual host and with the ip address 10.0.2.2. through configuring the host file and editing both the http.vhosts.conf and httpd.conf files appropriately.
I have seen the following threads and none provided the solution
Connection to LocalHost/10.0.2.2 from Android Emulator timed out
How to connect emulator to laravel server localhost:8000
http://www.4answered.com/questions/view/20e0ab1/How-to-connect-emulator-to-laravel-server-localhost8000#videoAnswer
The Error looks like this -
09-03 17:42:37.886 23713-23739/com.geniusesafrica.geniuses I/OpenGLRenderer: Initialized EGL, version 1.4
09-03 17:42:45.810 23713-23713/com.geniusesafrica.geniuses I/Choreographer: Skipped 476 frames! The application may be doing too much work on its main thread.
09-03 17:43:06.820 23713-23713/com.geniusesafrica.geniuses D/MainActivity: onFailure: .failed to connect to /10.0.2.2 (port 8000) after 10000ms
09-03 17:43:06.826 23713-23713/com.geniusesafrica.geniuses I/Choreographer: Skipped 1259 frames! The application may be doing too much work on its main thread.
09-03 17:43:06.829 23713-23782/com.geniusesafrica.geniuses D/FA: Connected to remote service
09-03 17:43:06.829 23713-23782/com.geniusesafrica.geniuses V/FA: Processing queued up service tasks: 1
09-03 17:43:11.867 23713-23782/com.geniusesafrica.geniuses V/FA: Inactivity, disconnecting from AppMeasurementService
And Here is the retrofit builder -
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://10.0.2.2:8000/api/")
.addConverterFactory(GsonConverterFactory.create(gson))
.build();
I can access my laravel app from the Machines browser and from postman as well and i can make requests from my emulator to remote addresses.
On the emulators browser the same url is giving the following error -
net:ERR_NAME_NOT_RESOLVED
then its timing out with a
net:ERR_CONNECTION_TIMED_OUT
Any help will be appreciated.

Categories

Resources