Appium sometimes stuck and not able to run the android tests or not launching the andorid app with error as below
“error: socket hang up“
This error may occur if the port is busy or uiautomator2 server not responding.
You can change the system port to something else other than the default 8200 with appium capabilities as –
UiAutomator2Options options = new UiAutomator2Options(); options.setSystemPort(8350)
and run the appium code to resolve the issue.
Sometimes the above might not work as the uiautomator2 server is not responding, then you can follow below steps to resolve the issue –
- Stop the appium server
- Open terminal and run below commands one by one –
adb uninstall io.appium.uiautomator2.server
adb uninstall io.appium.uiautomator2.server.test
- Now start the appium server and run the test
You should now able to run the android tests in appium successfully.