No Connected Devices

How to properly ensure device is connected and how to set the capabilities?

Windows 7
Java 1.8
Eclipse
TestNG

info: → POST /wd/hub/session {“desiredCapabilities”:{“appPackage”:“com.android.calculator2”,“appActivity”:“com.android.calculator2.Calculator”,“BROWSER_NAME”:“Android”,“VERSION”:“4.4.2”,“platformName”:“Android”,“udid”:“192.168.56.102:5555”,“deviceName”:“Emulator”},“requiredCapabilities”:{},“capabilities”:{“desiredCapabilities”:{“appPackage”:“com.android.calculator2”,“appActivity”:“com.android.calculator2.Calculator”,“BROWSER_NAME”:“Android”,“VERSION”:“4.4.2”,“platformName”:“Android”,“udid”:“192.168.56.102:5555”,“deviceName”:“Emulator”},“requiredCapabilities”:{}},“alwaysMatch”:{“appPackage”:“com.android.calculator2”,“appActivity”:“com.android.calculator2.Calculator”,“BROWSER_NAME”:“Android”,“VERSION”:“4.4.2”,“platformName”:“Android”,“udid”:“192.168.56.102:5555”,“deviceName”:“Emulator”},“firstMatch”:}
info: Client User-Agent string: Apache-HttpClient/4.5.2 (Java/1.8.0_91)
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. : BROWSER_NAME, VERSION
info: [debug] Didn’t get app but did get Android package, will attempt to launch it on the device
info: [debug] Creating new appium session 040300f4-8de4-4008-9933-606c0ba86cd6
info: Starting android appium
info: [debug] Getting Java version
info: Java version is: 1.8.0_91
info: [debug] Checking whether adb is present
info: [debug] Using adb from C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe
warn: No app capability, can’t parse package/activity
info: [debug] Using fast reset? true
info: [debug] Preparing device for session
info: [debug] Not checking whether app is present since we are assuming it’s already on the device
info: Retrieving device
info: [debug] Trying to find a connected android device
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Could not find devices, restarting adb server…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe kill-server
info: [debug] Getting connected devices…
info: [debug] executing cmd: C:\Users\DRamer\AppData\Local\Android\Sdk\platform-tools\adb.exe devices
info: [debug] 0 device(s) connected
info: [debug] Sent shutdown command, waiting for UiAutomator to stop…
warn: UiAutomator did not shut down fast enough, calling it gone
info: [debug] Cleaning up android objects
info: [debug] Cleaning up appium session
error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.
info: [debug] Error: Could not find a connected Android device.
at [object Object].ADB.getDevicesWithRetry (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:606:15)
at [object Object].androidCommon.prepareActiveDevice (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:400:12)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:326:26)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].androidCommon.ensureDeviceLocale (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:371:45)
at [object Object].androidCommon.prepareEmulator (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:364:10)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:325:26)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].androidCommon.checkAppPresent (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:336:5)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:324:26)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at async.eachSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:162:9)
at _asyncMap (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:245:13)
at Object.mapSeries (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:228:23)
at Object.async.series (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:605:19)
at [object Object].androidCommon.prepareDevice (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:323:9)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].Android.initUiautomator (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:140:10)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object].androidCommon.packageAndLaunchActivityFromManifest (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:670:12)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1086:7)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:74:5
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:137:5)
at [object Object].ADB.checkSdkBinaryPresent (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:116:5)
at [object Object].ADB.checkAdbPresent (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:134:8)
at Function.ADB.createADB (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:73:7)
at [object Object].androidCommon.initAdb (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1083:9)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1077:12)
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:1064:12)
at ChildProcess.exithandler (child_process.js:742:7)
info: [debug] Responding to client with error: {“status”:33,“value”:{“message”:“A new session could not be created. (Original error: Could not find a connected Android device.)”,“origValue”:“Could not find a connected Android device.”},“sessionId”:null}
info: ← POST /wd/hub/session 500 27911.045 ms - 206

Verify your device is connected to your windows machine before starting appium. You can do this using adb. You should also verify that adb access to your device is enabled, which can only be true if you have enabled developer options on your android device.

type adb devices in cmd
if device is not there then
1.check usb debugging is on in developer section of android
2.if yes check driver of device is installed on machine
3.if not install driver of that device

I followed the Android SDK process to install the driver and it works.

http://visualgdb.com/KB/usbdebug-manual/