Appium session, could not find a connected Android device. Shows error
<p><strong>Appium session, could not find a connected Android device.  Shows error in eclipse</strong> </p>

<p>If any one know how to fix please let me know. </p>

<p>**The Junit code: - **</p>

<pre><code>    import static org.junit.Assert.*;
    import java.io.File;
    import java.net.MalformedURLException;
    import java.net.URL;
    import org.junit.Test;
    import org.openqa.selenium.remote.DesiredCapabilities;
    import io.appium.java_client.android.AndroidDriver;
    import io.appium.java_client.remote.MobileCapabilityType;
    import io.appium.java_client.remote.MobilePlatform;

    public class desiredCapab {

        @Test
        public void test() throws MalformedURLException {

            File appDir = new File("C:\\Eclipse-Neon\\Project\\AppiumT\\Apk\\");

                File app = new File (appDir, "WhatsApp.apk");


            DesiredCapabilities cap = new DesiredCapabilities();
            cap.setCapability(MobileCapabilityType.PLATFORM_NAME,MobilePlatform.ANDROID);
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
cap.setCapability(MobileCapabilityType.APP, app.getAbsolutePath());

AndroidDriver driver = new AndroidDriver(new URL ("http://127.0.0.1:4723/wd/hub"), cap);

            //{"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"23","automationName":"Appium"}
        }
    }
</code></pre>

<p><strong>Eclipse Junit Error :-</strong> </p>

<p>org.openqa.selenium.SessionNotCreatedException: A new session could not be created. (Original error: Could not find a connected Android device.) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 28.61 seconds
Build info: version: '2.49.0', revision: '365eeb4', time: '2016-01-13 18:33:29'
System info: host: 'DESKTOP-PC1SJR4', ip: '192.168.1.104', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_91'</p>

<p><strong>AVD manager setting: - Image</strong> </p>

<p><a href="https://i.stack.imgur.com/1Nvcs.png" rel="nofollow"><img src="https://i.stack.imgur.com/1Nvcs.png" alt="enter image description here"></a></p>

<p><strong>Appium :- Error message</strong> </p>

<pre><code>&gt; info: --&gt; POST /wd/hub/session {"desiredCapabilities":{"app":"C:\\Eclipse-Neon\\Project\\AppiumT\\Apk\\WhatsApp.apk","platformName":"Android","deviceName":"Android Emulator"}}
&gt; info: Client User-Agent string: Apache-HttpClient/4.5.1 (Java/1.8.0_91)
&gt; info: [debug] No appActivity desired capability or server param. Parsing from apk.
&gt; info: [debug] No appPackage desired capability or server param. Parsing from apk.
&gt; info: [debug] Using local app from desired caps: C:\Eclipse-Neon\Project\AppiumT\Apk\WhatsApp.apk
&gt; info: [debug] Creating new appium session c9232f90-f519-4058-9e80-22cd2830de57
&gt; info: Starting android appium
&gt; info: [debug] Getting Java version
&gt; info: Java version is: 1.8.0_101
&gt; info: [debug] Checking whether adb is present
&gt; info: [debug] Using adb from C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe
&gt; info: [debug] Parsing package and activity from app manifest
&gt; info: [debug] Checking whether aapt is present
&gt; info: [debug] Using aapt from C:\Users\bizBoxChat\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe
&gt; info: [debug] Extracting package and launch activity from manifest.
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\build-tools\24.0.3\aapt.exe dump badging C:\Eclipse-Neon\Project\AppiumT\Apk\WhatsApp.apk
&gt; info: [debug] badging package: com.whatsapp
&gt; info: [debug] badging act: com.whatsapp.Main
&gt; info: [debug] Parsed package and activity are: com.whatsapp/com.whatsapp.Main
&gt; info: [debug] Using fast reset? true
&gt; info: [debug] Preparing device for session
&gt; info: [debug] Checking whether app is actually present
&gt; info: Retrieving device
&gt; info: [debug] Trying to find a connected android device
&gt; info: [debug] Getting connected devices...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
&gt; info: [debug] 0 device(s) connected
&gt; info: [debug] Could not find devices, restarting adb server...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
&gt; info: [debug] Getting connected devices...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
&gt; info: [debug] 0 device(s) connected
&gt; info: [debug] Could not find devices, restarting adb server...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
&gt; info: [debug] Getting connected devices...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
&gt; info: [debug] 0 device(s) connected
&gt; info: [debug] Could not find devices, restarting adb server...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
&gt; info: [debug] Getting connected devices...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
&gt; info: [debug] 0 device(s) connected
&gt; info: [debug] Could not find devices, restarting adb server...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe kill-server
&gt; info: [debug] Getting connected devices...
&gt; info: [debug] executing cmd: C:\Users\bizBoxChat\AppData\Local\Android\sdk\platform-tools\adb.exe devices
&gt; info: [debug] 0 device(s) connected
&gt; info: [debug] Sent shutdown command, waiting for UiAutomator to stop...
&gt; warn: UiAutomator did not shut down fast enough, calling it gone
&gt; info: [debug] Cleaning up android objects
&gt; info: [debug] Cleaning up appium session
&gt; error: Failed to start an Appium session, err was: Error: Could not find a connected Android device.
&gt; info: [debug] Error: Could not find a connected Android device.
&gt;     at [object Object].ADB.getDevicesWithRetry (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\lib\adb.js:606:15)
&gt;     at [object Object].androidCommon.prepareActiveDevice (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:400:12)
&gt;     at [object Object].&lt;anonymous&gt; (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:326:26)
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
&gt;     at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
&gt;     at [object Object].androidCommon.ensureDeviceLocale (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:371:45)
&gt;     at [object Object].androidCommon.prepareEmulator (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:364:10)
&gt;     at [object Object].&lt;anonymous&gt; (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:325:26)
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:607:21
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:246:17
&gt;     at iterate (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:146:13)
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:157:25
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:248:21
&gt;     at C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:612:34
&gt;     at [object Object].&lt;anonymous&gt; (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android-common.js:344:9)
&gt;     at FSReqWrap.oncomplete (fs.js:95:15)
&gt; 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}
&gt; info: &lt;-- POST /wd/hub/session 500 28492.200 ms - 206
</code></pre>