Unable to launch selendroid server using appium

HI All,

I’m trying to execute my test cases with selendroid mode. I always get “could not bind socket” when i do it with Appium.
However I’m able to execute my test suit if I start the selendroid server by command line rather than Appium with selendroid mode.

Is there any way I can use only the Appium for selendroid?
Or Selendroid mode in appium is not working for anyone.
If someone has successfully achieved it using only Appium please share the step.(video or elaborated step)

Here are the logs I’m getting from Appium

Starting Node Server
info: Welcome to Appium v1.3.4 (REV c8c79a85fbd6870cd6fc3d66d038a115ebe22efe)
info: Appium REST http interface listener started on 127.0.0.1:4723
info: [debug] Non-default server args: {“address”:“127.0.0.1”,“logNoColors”:true,“avd”:“Selendroid_Appium”,“platformName”:“Android”,“platformVersion”:“15”,“automationName”:“Selendroid”}
info: Console LogLevel: debug
info: → GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}
info: ← GET /wd/hub/status 304 5.409 ms - - {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}
info: → POST /wd/hub/session {“desiredCapabilities”:{“platform”:“Android”,“app”:"C:\Users\dharamveerr\Desktop\SPH\build_27_feb\-release.apk",“platformName”:“Android”,“deviceName”:“”,“app-package”:"..“,“app-activity”:”...activities.SplashVideoActivity",“version”:“”}}
info: Client User-Agent string: Apache-HttpClient/4.3.2 (java 1.5)
info: [debug] The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : platform, app-package, app-activity, version
info: [debug] No appActivity desired capability or server param. Parsing from apk.
info: [debug] No appPackage desired capability or server param. Parsing from apk.
info: [debug] Using local app from desired caps: C:\Users\dharamveerr\Desktop\SPH\build_27_feb*-release.apk
info: [debug] Creating new appium session 3aa8ed9f-c7c1-4bd0-9866-fff6d9386ae3
info: [debug] Starting selendroid server
info: [debug] Getting Java version
info: Java version is: 1.7.0_55
info: [debug] Checking whether selendroid is built yet
info: [debug] Selendroid server exists!
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Checking whether app is actually present
info: [debug] Checking whether adb is present
info: [debug] Using adb from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe
info: [debug] Trying to find Selendroid_Appium emulator
info: [debug] Getting connected emulators
info: [debug] Getting connected devices…
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe devices
info: [debug] 1 device(s) connected
info: [debug] 1 emulator(s) connected
info: [debug] Sending telnet command to device: avd name
info: [debug] Getting running emulator port
info: [debug] Socket connection to device created
info: [debug] Socket connection to device ready
info: [debug] Telnet command got response: Selendroid_Appium
info: [debug] Found emulator Selendroid_Appium in port 5554
info: [debug] Setting device id to emulator-5554
info: [debug] Did not launch AVD because it was already running.
info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5)
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 wait-for-device
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “echo ‘ready’”
info: [debug] Starting logcat capture
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\aapt.exe
info: [debug] Checking if has internet permission from manifest.
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\aapt.exe dump badging C:\Users\dharamveerr\Desktop\SPH\build_27_feb*
-release.apk
info: [debug] Parsing package and activity from app manifest
info: [debug] Checking whether aapt is present
info: [debug] Using aapt from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\aapt.exe
info: [debug] Extracting package and launch activity from manifest.
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\android-4.4\aapt.exe dump badging C:\Users\dharamveerr\Desktop\SPH\build_27_feb**************-release.apk
info: [debug] badging package: ..
***
info: [debug] badging act: ...activities.SplashVideoActivity
info: [debug] Parsed package and activity are: ..
/...activities.SplashVideoActivity
info: [debug] Rebuilt selendroid server already exists, no need to rebuild it with a new manifest
info: [debug] Checking signed status of C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
.
..apk
info: [debug] Checking app cert for C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
.
..apk.
info: [debug] executing cmd: java -jar C:\Users\dharamveerr\Desktop\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
...apk
info: [debug] Checking signed status of C:\Users\dharamveerr\Desktop\SPH\build_27_feb*-release.apk
info: [debug] Checking app cert for C:\Users\dharamveerr\Desktop\SPH\build_27_feb*
-release.apk.
info: [debug] executing cmd: java -jar C:\Users\dharamveerr\Desktop\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\dharamveerr\Desktop\SPH\build_27_feb********-release.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
.
.
.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe -f 4 C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
...apk C:\Users\DHARAM~1\AppData\Local\Temp\appium11523-10204-aw9t5v.tmp
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\dharamveerr\Desktop\SPH\build_27_feb*-release.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe -f 4 C:\Users\dharamveerr\Desktop\SPH\build_27_feb*
-release.apk C:\Users\DHARAM~1\AppData\Local\Temp\appium11523-10204-1v863yw.tmp
info: [debug] Rebuilt selendroid apk does not exist, uninstalling any instances of it on device to make way for new one
info: [debug] Uninstalling ..
.selendroid
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell "am force-stop ..
.selendroid"
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 uninstall ..
.selendroid
info: [debug] App was uninstalled
info: [debug] Getting install status for ..
.selendroid
info: [debug] Getting device API level
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 15
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell "pm list packages -3 ..
.selendroid"
info: [debug] App is not installed
info: [debug] Rebuilt selendroid is not installed, installing it
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 install -r "C:\Users\DHARAM~1\AppData\Local\Temp\selendroid.
...apk"
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop persist.sys.language”
info: [debug] Current device persist.sys.language: en
info: [debug] java -jar “C:\Users\dharamveerr\Desktop\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar” “stringsFromApk” “C:\Users\dharamveerr\Desktop\SPH\build_27_feb**************-release.apk” "C:\Users\DHARAM~1\AppData\Local\Temp*
.." en
info: [debug] No strings.xml for language ‘en’, getting default strings.xml
info: [debug] java -jar “C:\Users\dharamveerr\Desktop\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar” “stringsFromApk” “C:\Users\dharamveerr\Desktop\SPH\build_27_feb**************-release.apk” "C:\Users\DHARAM~1\AppData\Local\Temp*
.."
info: [debug] Not uninstalling app since server not started with --full-reset
info: [debug] Checking app cert for C:\Users\dharamveerr\Desktop\SPH\build_27_feb*-release.apk.
info: [debug] executing cmd: java -jar C:\Users\dharamveerr\Desktop\AppiumForWindows-1.3.4.1\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar C:\Users\dharamveerr\Desktop\SPH\build_27_feb*
-release.apk
info: [debug] App already signed.
info: [debug] Zip-aligning C:\Users\dharamveerr\Desktop\SPH\build_27_feb*-release.apk
info: [debug] Checking whether zipalign is present
info: [debug] Using zipalign from D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe
info: [debug] Zip-aligning apk.
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\build-tools\21.1.2\zipalign.exe -f 4 C:\Users\dharamveerr\Desktop\SPH\build_27_feb*
-release.apk C:\Users\DHARAM~1\AppData\Local\Temp\appium11523-10204-y7my3k.tmp
info: [debug] MD5 for app is fe75abf5ca071a0fe47ca6b0bafa636b
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “ls /data/local/tmp/fe75abf5ca071a0fe47ca6b0bafa636b.apk”
info: [debug] Getting install status for ..
***
info: [debug] Getting device API level
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “getprop ro.build.version.sdk”
info: [debug] Device is at API Level 15
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “pm list packages -3 .."
info: [debug] App is installed
info: App is already installed, resetting app
info: [debug] Running fast reset (stop and clear)
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell "am force-stop ..

info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 shell “pm clear ..*****”
info: [debug] Forwarding system:8080 to device:8080
info: [debug] executing cmd: D:\Appium\adt-bundle\adt-bundle-windows-x86_64-20131030\sdk\platform-tools\adb.exe -s emulator-5554 forward tcp:8080 tcp:8080
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Command failed: error: cannot bind to socket
error: cannot bind to socket

info: [debug] Error: Command failed: error: cannot bind to socket
error: cannot bind to socket

at ChildProcess.exithandler (child_process.js:637:15)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:743:16)
at Process.ChildProcess._handle.onexit (child_process.js:810:5)

info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Command failed: error: cannot bind to socket\r\nerror: cannot bind to socket\r\n)”,“killed”:false,“code”:1,“signal”:null,“origValue”:“Command failed: error: cannot bind to socket\r\nerror: cannot bind to socket\r\n”},“sessionId”:null}
info: ← POST /wd/hub/session 500 22447.137 ms - 320
info: → GET /wd/hub/status {}
info: [debug] Responding to client with success: {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}
info: ← GET /wd/hub/status 304 1.675 ms - - {“status”:0,“value”:{“build”:{“version”:“1.3.4”,“revision”:“c8c79a85fbd6870cd6fc3d66d038a115ebe22efe”}}}

Hi Team ,

Appium version : 1.3.4.1

I got solution please find below information.

            File appDir = new File("App path");
	File app = new File(appDir, "Apk");
	DesiredCapabilities capabilities = new DesiredCapabilities();
	capabilities.setCapability("deviceName", "");
	capabilities.setCapability("automationName", "Selendroid");
	capabilities.setCapability("platformVersion", "4.0");
	capabilities.setCapability("platformName", "Android");
	capabilities.setCapability("appPackage", "PakageName");
	capabilities.setCapability("appium-version", "");
	capabilities.setCapability("app", app.getAbsolutePath());
	capabilities.setCapability(CapabilityType.PLATFORM, "WINDOW");
	capabilities.setCapability("appactivity", "com.wordpad.Main");
	driver = new SelendroidDriver(new URL("http://127.0.0.1:4723/wd/hub"),
	capabilities);

Snapshot contains parameter of Appium.

Let me know if you have any query/more info related to this.

Best,

Dharamveer

Can you just verify that nothing else is running on port 8080 on your system?